1    package geekblog.tags;
2    
3    
4    import javax.servlet.*;
5    import javax.servlet.jsp.*;
6    import javax.servlet.jsp.tagext.*;
7    
8    
9    /**
10    * A tag that will "entity-escape" any HTML tags within it.
11    */
12   public class HTMLEscapeTag extends BodyTagSupport
13   {
14     public int doAfterBody()
15       throws JspException
16     {
17       String body = bodyContent.getString();
18   
19       body = body.replaceAll("&", "&");
20       body = body.replaceAll("<", "<");
21       body = body.replaceAll(">", ">");
22   
23       try
24       {
25         getPreviousOut().print(body);
26       }
27       catch (java.io.IOException ioEx)
28       {
29         // Ignore it--will never be thrown
30       }
31   
32       return SKIP_BODY;
33     }
34   }
35