title: Custom Tag - JspWriter.write() produces no output
body: <p>My custom tag (handler is <code>printSomething.java</code>, which implements <code>Tag</code>) is running, but not producing expected output. I was expecting to see "The tag works!", but only my   template text is displaying. Am I misusing the JspWriter? Code and output below.</p>
  
  <p><strong>printSomething.java</strong></p>
  
  <pre><code>package webcert.ch08.x0804;
  import java.io.IOException;
  import java.io.PrintWriter;
  
  import javax.servlet.jsp.JspWriter;
  import javax.servlet.jsp.PageContext;
  import javax.servlet.jsp.tagext.Tag;
  
  public class printSomething implements Tag{
  
  private PageContext pc;
  private Tag parent;
  
  public void setPageContext(PageContext pc){
      this.pc = pc;
  }
  public void setParent(Tag parent){
      this.parent = parent;
  }
  public Tag getParent(){
      return parent;
  }
  public int doStartTag(){
      try{
          printMessage();
      }
      catch(IOException ioe){}
      return Tag.SKIP_BODY;
  }
  public int doEndTag(){
      return Tag.EVAL_PAGE;
  }
  public void release(){
  
  }
  public void printMessage() throws IOException{
      JspWriter out = pc.getOut();
      out.write("&lt;b&gt;The tag works!&lt;/b&gt;");
      out.print("&lt;b&gt;The tag works!&lt;/b&gt;");
      out.flush();
  }
  
  }
  </code></pre>
  
  <p><strong>practice.jspx</strong></p>
  
  <pre><code>&lt;html xmlns:mytags="http://www.ets.com/mytags"
  xmlns:jsp="http://java.sun.com/JSP/Page"&gt;
  
  &lt;jsp:output omit-xml-declaration="true"/&gt;
  &lt;jsp:directive.page contentType="text/html"/&gt;
  
  &lt;head&gt;&lt;title&gt;Practice JSPX&lt;/title&gt;&lt;/head&gt;
    &lt;body&gt;
      BEFORE&lt;br/&gt;
      &lt;mytags:printSomething/&gt;&lt;br/&gt;
      AFTER&lt;br/&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;web-app&gt;
    &lt;jsp-config&gt;
      &lt;taglib-uri&gt;http://www.ets.com/mytags&lt;/taglib-uri&gt;
      &lt;taglib-location&gt;/WEB-INF/tags/mytags.tld&lt;/taglib-location&gt;
    &lt;/jsp-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p><strong>mytags.tld</strong></p>
  
  <pre><code>&lt;taglib xmlns="http://java.sun.com/xml/ns/j2ee" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-
  jsptaglibrary_2_0.xsd" 
  version="2.0"&gt;
  
    &lt;tlib-version&gt;1.0&lt;/tlib-version&gt;
    &lt;short-name&gt;some tags&lt;/short-name&gt;
    &lt;tag&gt;
      &lt;name&gt;printSomething&lt;/name&gt;
      &lt;tag-class&gt;webcert.ch08.x0804.PrintSomething&lt;/tag-class&gt;
      &lt;body-content&gt;empty&lt;/body-content&gt;
    &lt;/tag&gt;
  &lt;/taglib&gt;
  </code></pre>
  
  <p><strong>output</strong></p>
  
  <pre><code>BEFORE
  
  AFTER
  </code></pre>