Spring Framework

org.springframework.web.servlet.tags
Class EscapeBodyTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by org.springframework.web.servlet.tags.RequestContextAwareTag
          extended by org.springframework.web.servlet.tags.HtmlEscapingAwareTag
              extended by org.springframework.web.servlet.tags.EscapeBodyTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag, javax.servlet.jsp.tagext.TryCatchFinally

public class EscapeBodyTag
extends HtmlEscapingAwareTag
implements javax.servlet.jsp.tagext.BodyTag

Custom JSP tag to escape its enclosed body content, applying HTML escaping and/or JavaScript escaping.

Provides a "htmlEscape" property for explicitly specifying whether to apply HTML escaping. If not set, a page-level default (e.g. from the HtmlEscapeTag) or an application-wide default (the "defaultHtmlEscape" context-param in web.xml) is used.

Provides a "javaScriptEscape" property for specifying whether to apply JavaScript escaping. Can be combined with HTML escaping or used standalone.

Since:
1.1.1
Author:
Juergen Hoeller
See Also:
HtmlUtils, JavaScriptUtils, Serialized Form

Field Summary
 
Fields inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
logger, REQUEST_CONTEXT_PAGE_ATTRIBUTE
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
EscapeBodyTag()
           
 
Method Summary
 int doAfterBody()
           
 void doInitBody()
           
protected  int doStartTagInternal()
          Called by doStartTag to perform the actual work.
protected  java.lang.String readBodyContent()
          Read the unescaped body content from the page.
 void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
           
 void setJavaScriptEscape(java.lang.String javaScriptEscape)
          Set JavaScript escaping for this tag, as boolean value.
protected  void writeBodyContent(java.lang.String content)
          Write the escaped body content to the page.
 
Methods inherited from class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
isDefaultHtmlEscape, isHtmlEscape, setHtmlEscape
 
Methods inherited from class org.springframework.web.servlet.tags.RequestContextAwareTag
doCatch, doFinally, doStartTag, getRequestContext
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doEndTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
doEndTag, doStartTag, getParent, release, setPageContext, setParent
 

Constructor Detail

EscapeBodyTag

public EscapeBodyTag()
Method Detail

setJavaScriptEscape

public void setJavaScriptEscape(java.lang.String javaScriptEscape)
                         throws javax.servlet.jsp.JspException
Set JavaScript escaping for this tag, as boolean value. Default is "false".

Throws:
javax.servlet.jsp.JspException

doStartTagInternal

protected int doStartTagInternal()
Description copied from class: RequestContextAwareTag
Called by doStartTag to perform the actual work.

Specified by:
doStartTagInternal in class RequestContextAwareTag
Returns:
same as TagSupport.doStartTag
See Also:
TagSupport.doStartTag()

doInitBody

public void doInitBody()
Specified by:
doInitBody in interface javax.servlet.jsp.tagext.BodyTag

setBodyContent

public void setBodyContent(javax.servlet.jsp.tagext.BodyContent bodyContent)
Specified by:
setBodyContent in interface javax.servlet.jsp.tagext.BodyTag

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.TagSupport
Throws:
javax.servlet.jsp.JspException

readBodyContent

protected java.lang.String readBodyContent()
                                    throws java.io.IOException
Read the unescaped body content from the page.

Returns:
the original content
Throws:
java.io.IOException - if reading failed

writeBodyContent

protected void writeBodyContent(java.lang.String content)
                         throws java.io.IOException
Write the escaped body content to the page.

Can be overridden in subclasses, e.g. for testing purposes.

Parameters:
content - the content to write
Throws:
java.io.IOException - if writing failed

Spring Framework