public class

EscapeBodyTag

extends HtmlEscapingAwareTag
java.lang.Object
   ↳ TagSupport
     ↳ org.springframework.web.servlet.tags.RequestContextAwareTag
       ↳ org.springframework.web.servlet.tags.HtmlEscapingAwareTag
         ↳ org.springframework.web.servlet.tags.EscapeBodyTag

Class Overview

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.

Summary

[Expand]
Inherited Constants
From class org.springframework.web.servlet.tags.RequestContextAwareTag
[Expand]
Inherited Fields
From class org.springframework.web.servlet.tags.RequestContextAwareTag
Public Constructors
EscapeBodyTag()
Public Methods
int doAfterBody()
void doInitBody()
void setBodyContent(BodyContent bodyContent)
void setJavaScriptEscape(String javaScriptEscape)
Set JavaScript escaping for this tag, as boolean value.
Protected Methods
int doStartTagInternal()
Called by doStartTag to perform the actual work.
String readBodyContent()
Read the unescaped body content from the page.
void writeBodyContent(String content)
Write the escaped body content to the page.
[Expand]
Inherited Methods
From class org.springframework.web.servlet.tags.HtmlEscapingAwareTag
From class org.springframework.web.servlet.tags.RequestContextAwareTag
From class java.lang.Object

Public Constructors

public EscapeBodyTag ()

Public Methods

public int doAfterBody ()

Throws
JspException

public void doInitBody ()

public void setBodyContent (BodyContent bodyContent)

public void setJavaScriptEscape (String javaScriptEscape)

Set JavaScript escaping for this tag, as boolean value. Default is "false".

Throws
JspException

Protected Methods

protected int doStartTagInternal ()

Called by doStartTag to perform the actual work.

Returns
  • same as TagSupport.doStartTag

protected String readBodyContent ()

Read the unescaped body content from the page.

Returns
  • the original content
Throws
IOException if reading failed

protected void writeBodyContent (String content)

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
IOException if writing failed