Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:49:28+00:00 2026-06-11T17:49:28+00:00

The Cross Site Scripting Cheat Sheet has many rules for securing against XSS attacks.

  • 0

The Cross Site Scripting Cheat Sheet has many rules for securing against XSS attacks. I would like to implement those suggestions in my web app which is using Spring MVC + Jackson + JPA + Hibernate Bean Validation. As an example consider the following code that is similar to what I have in my app.

public class MessageJson {
    @NotEmpty // Bean Validation annotation  
    private String title; 

    @NotEmpty
    private String body; 

    // ... etc getters / setters
}

public class BolgPostController 
{ 
     
     @RequestMapping(value="messages",method=RequestMethod.POST) 
     public void createMessage(@Valid @RequestBody MessageJson message)
     {
           // **Question** How do I check that the message title and body don't contain 
           // nasty javascripts and other junk that should not be there? 

           // Call services to write data to the datababse
     }

     @RequestMapping(value="messages",method=RequestMethod.get) 
     public @ResponseBody List<MessageJson> createMessage()
     {
           // get data from the database 

           // **Question** How do I escape all the data in the list of MessageJson before 
            I send it back to the data. 
     }
}

I can see the following ways to implement the cheat sheet rules:

  • Option A Implement them manually in each controller method.
  • Option B Configure some extension to Spring MVC that can do it for me automatically
  • Option C Configure Jackson so that it can do it for me since most of my input/output goes through Jackson

I am looking for some example configurations of SpringMVC in any of those three options, with a preference for option B and C.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:49:29+00:00Added an answer on June 11, 2026 at 5:49 pm

    That would be easiest to do in setters for properties (like setTitle() for title property), when reading JSON.

    Or if you are thinking of escaping additional characters (to, say, prevent embedding of HTML markup), have a look at this blog entry: escaping HTML characters in JSON with Jackson.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does the XSS (Cross Site Scripting) support provided by ASP.net differs from AntiXss.
I know this has cross site scripting limitations however I was wondering if there
My application has lot of cross site scripting vulnerablities. I need a common C#
Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web
Will there be any problem like cross site scripting if I make a provision
Which type of input is least vulnerable to Cross-Site Scripting (XSS) and SQL Injection
Possible Duplicate: Best way to defend against mysql injection and cross site scripting Validating
I've got some source code that has some cross site scripting vulnerabilities in it.
I'm evaluating the Microsoft Anti-Cross Site Scripting Library (AntiXSS V3) I have to say
Is this regular expression enough to catch all cross site scripting attempts when embedding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.