- Direct Known Subclasses:
EncodingTag
,JavaScriptTag
,JsonTag
,LdJsonTag
,MysqlTag
,PsqlTag
,ShTag
,StyleTag
,TextTag
,UrlTag
,XhtmlAttributeTag
,XhtmlTag
SimpleTag
that automatically validates its
content and automatically encodes its output correctly given its context.
It also validates its own output when used in a non-validating context. For
higher performance, it filters the output from its body instead of buffering.
The content validation is primarily focused on making sure the contained data is properly encoded. This is to avoid data corruption or intermingling of data and code. It does not go through great lengths such as ensuring that XHTML Strict is valid or JavaScript will run correctly.
In additional to checking that its contents are well behaved, it also is
well behaved for its container by properly encoding its output for its
context. To determine its context, it uses the content type of the currently
registered RequestEncodingContext
to perform proper encoding.
If it fails to find any such context, it uses the content type of the
HttpServletResponse
.
Finally, if no existing RequestEncodingContext
is found, this will
validate its own output against the content type of the
HttpServletResponse
to make sure it is well-behaved.
- Author:
- AO Industries, Inc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
doTag()
Deprecated.protected void
abstract MediaType
Gets the type of data that is contained by this tag.protected void
setMediaEncoderOptions
(MediaEncoder mediaEncoder) Sets the media encoder options.protected void
writeEncoderPrefix
(MediaEncoder mediaEncoder, Writer out) protected void
writeEncoderSuffix
(MediaEncoder mediaEncoder, Writer out, boolean trim) protected void
writePrefix
(MediaType containerType, Writer out) Writes any prefix in the container's media type.protected void
writeSuffix
(MediaType containerType, Writer out) Writes any suffix in the container's media type.Methods inherited from class javax.servlet.jsp.tagext.SimpleTagSupport
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent
-
Constructor Details
-
EncodingFilteredTag
public EncodingFilteredTag()
-
-
Method Details
-
getContentType
Gets the type of data that is contained by this tag. This is used to determine the correct encoder. This is also the output type. -
doTag
Deprecated.You should probably be implementing indoTag(java.io.Writer)
- Specified by:
doTag
in interfaceSimpleTag
- Overrides:
doTag
in classSimpleTagSupport
- Throws:
JspException
IOException
- See Also:
-
writePrefix
Writes any prefix in the container's media type. The output must be valid for the provided type.This default implementation prints nothing.
- Parameters:
out
- Validates all characters against the container media type. Already optimized viaCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
.- Throws:
JspException
IOException
-
setMediaEncoderOptions
Sets the media encoder options. This is how subclass tag attributes can effect the encoding. -
writeEncoderPrefix
protected void writeEncoderPrefix(MediaEncoder mediaEncoder, Writer out) throws JspException, IOException - Parameters:
out
- Validates all characters against the container media type. Already optimized viaCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
.- Throws:
JspException
IOException
-
doTag
Once the outJspWriter
has been replaced to output the proper content type, this version ofdoTag()
is called.This implementation invokes
JspFragment.invoke(java.io.Writer)
of the JSP body, if present.- Parameters:
out
- Validates all characters against the content type. Already optimized viaCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
.- Throws:
JspException
IOException
-
writeEncoderSuffix
protected void writeEncoderSuffix(MediaEncoder mediaEncoder, Writer out, boolean trim) throws JspException, IOException - Parameters:
out
- Validates all characters against the container media type. Already optimized viaCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
.- Throws:
JspException
IOException
-
writeSuffix
Writes any suffix in the container's media type. The output must be valid for the provided type.This default implementation prints nothing.
- Parameters:
out
- Validates all characters against the container media type. Already optimized viaCoercion.optimize(java.io.Writer, com.aoapps.lang.io.Encoder)
.- Throws:
JspException
IOException
-
doTag(java.io.Writer)