My Java-based web application has been flagged for XSS vulnerabilities. What are the best practices or libraries I can use to prevent XSS attacks, such as input sanitization, output encoding, or using secure frameworks?
Specific code examples or recommendations for popular libraries would be appreciated.