001package bradleyross.j2ee.tags; 002import javax.servlet.jsp.JspException; 003// import javax.servlet.jsp.PageContext; 004import javax.servlet.jsp.JspWriter; 005import javax.servlet.jsp.tagext.TagSupport; 006// import javax.servlet.jsp.tagext.TagExtraInfo; 007import java.io.IOException; 008// import java.util.Enumeration; 009/** 010 * Demonstration custom body tag. 011 * 012 * <p>Use of this tag means that the 013 * material between the start and 014 * end tags must be a properly formed 015 * XML element with no in line code 016 * for JavaScript or CSS styles.</p> 017 * 018 * @author Bradley Ross 019 */ 020@SuppressWarnings("serial") 021public class Body extends TagSupport 022{ 023 public int doStartTag() throws JspException 024 { 025 try 026 { 027 JspWriter out = pageContext.getOut(); 028 out.println("<body>"); 029 } 030 catch (IOException e) 031 { 032 throw new JspException("doStartTag: " + e.getClass().getName() + " " + e.getMessage()); 033 } 034 return EVAL_BODY_INCLUDE; 035 } 036 public int doEndTag() throws JspException 037 { 038 try 039 { 040 JspWriter out = pageContext.getOut(); 041 out.println("<hr />"); 042 out.println("<p><a href=\"index.html\">Go to main index page</a></p>"); 043 out.print("</body>"); 044 } 045 catch (IOException e) 046 { 047 throw new JspException("doEndTag: " + e.getClass().getName() + " " + e.getMessage()); 048 } 049 return EVAL_PAGE; 050 } 051}