
How to Prevent XSS in Java Web Applications Step by Step
Prevent cross-site scripting in Java web apps with context-aware output encoding, safe template settings, a Content Security Policy and sanitizing rich text.
Tag
8 posts

Prevent cross-site scripting in Java web apps with context-aware output encoding, safe template settings, a Content Security Policy and sanitizing rich text.

Stop path traversal by resolving user-supplied names against a base directory, normalizing and checking the result, and avoiding user input in paths.

Stop SQL injection in Java by binding values with parameters in JDBC, JPA and Spring, allow-listing identifiers and limiting what the database account can do.

Accept file uploads in Struts 2 with size and type limits, safe file names and storage outside the web root, and know which settings and releases matter.

Stop cross-site request forgery with Spring Security's CSRF tokens, SameSite cookies and Origin checks, and know when a stateless API can skip the token.

Learn where Struts 2 evaluates OGNL, why user input must never reach an expression, and which settings and habits keep the value stack safe.

Secure a Micronaut API with JWT bearer tokens: configure signing, issue a token from a login endpoint and protect routes with annotations and roles.

A defensive checklist for Struts 2: upgrade, restrict method and parameter access, limit OGNL, check uploads and reduce what the server can do.