EscapeTool Class - Documentation topics on: escapetool,velocity tools,.

This documentation is a static copy for this version. For current documentation, see:

EscapeTool Class
Class EscapeTool


extended by

public class EscapeTool
extends java.lang.Object

Tool for working with escaping in Velocity templates. It provides methods to escape outputs for Java, JavaScript, HTML, XML and SQL. Also provides methods to render VTL characters that otherwise needs escaping.


Example uses:
$java -> He didn't say, "Stop!"
$$java) -> He didn't say, \"Stop!\"

$javascript -> He didn't say, "Stop!"
$esc.javascript($javascript) -> He didn\'t say, \"Stop!\"

$html -> "bread" & "butter"
$esc.html($html) -> "bread" & "butter"

$xml -> "bread" & "butter"
$esc.xml($xml) -> "bread" & "butter"

$sql -> McHale's Navy
$esc.sql($sql) -> McHale''s Navy

$esc.dollar -> $
$esc.d -> $

$esc.hash -> #
$esc.h -> #

$esc.backslash -> \
$esc.b -> \

$esc.quote -> "
$esc.q -> "

$esc.singleQuote -> '
$esc.s -> '

$esc.exclamation -> !
$esc.e -> !

Example toolbox.xml config (if you want to use this with VelocityView):

This tool is entirely threadsafe, and has no instance members. It may be used in any scope (request, session, or application).


VelocityTools 1.2
$Id: $
Shinobu Kawai
See Also:

For complete documentation on this viewtool use the following link: EscapeTool