• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## OWASP Java Encoder
2
3The OWASP Java Encoder is a collection of high-performance low-overhead
4contextual encoders that, when utilized correctly, is an effective tool in
5preventing Web Application security vulnerabilities such as Cross-Site
6Scripting (XSS).
7
8Please see the [OWASP XSS Prevention Cheat Sheet](https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet)
9for more information on preventing XSS.
10
11For use within JSP pages consider using the [JSP Encoder](../encoder-jsp/index.html) as it
12provides a TLD to make the use of the core encoders easier.
13
14### Usage
15
16The JARs can be found in [Maven Central](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.owasp.encoder%22).
17
18```xml
19<dependency>
20    <groupId>org.owasp.encoder</groupId>
21    <artifactId>encoder</artifactId>
22    <version>1.2.3</version>
23</dependency>
24```
25
26Utilize the encoder:
27
28```java
29import org.owasp.encoder.Encode;
30
31//...
32
33PrintWriter out = ....;
34out.println("<textarea>" + Encode.forHtml(userData) + "</textarea>");
35```
36