Class EscapeBodyTag

java.lang.Object
jakarta.servlet.jsp.tagext.TagSupport
All Implemented Interfaces:
jakarta.servlet.jsp.tagext.BodyTag, jakarta.servlet.jsp.tagext.IterationTag, jakarta.servlet.jsp.tagext.JspTag, jakarta.servlet.jsp.tagext.Tag, jakarta.servlet.jsp.tagext.TryCatchFinally, Serializable

public class EscapeBodyTag extends HtmlEscapingAwareTag implements jakarta.servlet.jsp.tagext.BodyTag
The <escapeBody> tag is used 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 (for example, 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.

Attribute Summary
Attribute Required? Runtime Expression? Description
htmlEscape false true Set HTML escaping for this tag, as boolean value. Overrides the default HTML escaping setting for the current page.
javaScriptEscape false true Set JavaScript escaping for this tag, as boolean value. Default is false.
Since:
1.1.1
Author:
Juergen Hoeller
See Also:
  • Constructor Details

    • EscapeBodyTag

      public EscapeBodyTag()
  • Method Details

    • setJavaScriptEscape

      public void setJavaScriptEscape(boolean javaScriptEscape) throws jakarta.servlet.jsp.JspException
      Set JavaScript escaping for this tag, as boolean value. Default is "false".
      Throws:
      jakarta.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 jakarta.servlet.jsp.tagext.BodyTag
    • setBodyContent

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

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

      protected String readBodyContent() throws IOException
      Read the unescaped body content from the page.
      Returns:
      the original content
      Throws:
      IOException - if reading failed
    • writeBodyContent

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

      Can be overridden in subclasses, for example, for testing purposes.

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