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

  • Home
  • SEARCH
  • 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 166137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:02:42+00:00 2026-05-11T12:02:42+00:00

we have a J2EE web application usig Spring MVC. We have a new requirement

  • 0

we have a J2EE web application usig Spring MVC. We have a new requirement for our web application where we have to remove certain pre-defined characters from the user input. For example, let’s say that the application should remove ‘<‘ from all the user inputs. I have come up with 2 approaches to meet this requirement :

  1. JSP Level : identify each and every jsp which allows user input and then remove the characters by client side processing.

  2. Servlet Filter : Use a filter and intercept the request object. Here I can use 1 of the following 2 approaches :

    2.1 : Override the request.getParameter method and write the character removal logic inside it. Whenever this method is called, it will return the filtered result.

    2.2 : At the filter level, scan the parameter map and filter the required characters. Then write a setParameter method and set the new values in the request parameter map.

Which approach do you suggest? Will the filter have any impact on the performance? If you can think of a better approach then please let me know.

  • 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. 2026-05-11T12:02:42+00:00Added an answer on May 11, 2026 at 12:02 pm

    You can do client-side filtering if you wish but you absolutely should not rely on it. Clients can turn off Javascript. They can also just post what they like when it comes down to it. Client-side validation is a convenience. It is no substitute for server-side validation.

    As for using servlet filters, I’m not sure I’m a big fan of that. It seems like (and I could be wrong here) you’re trying to protect yourself from lazy, forgetful or just plain inept developers.

    Also if you allow HTML at any point (like this site does), you can’t institute that sort of thing as a universal rule. This sort of thing should be handled where you do all your other validation. Put unit tests around it if you’re really worried about it.

    Servlet filters just seems heavyhanded and possibly problematic for this.

    You’re using Spring MVC. Are you using any particular validation framework behind Spring’s validators? Whatever the case, IMHO this is the correct place to deal with this kind of problem and easily unit-testable [sic].

    I think that’s the right point for this kind of thing.

    All that being said, I don’t see any technical reason why you couldn’t do this with setParameter in a servlet filter if you really are so inclined towards that approach. I would certainly do that over overriding setParameter on the servlet request. Can you even do that? Even if you can I wouldn’t.

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

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The $tabs variable normally gets populated with menu entries of… May 12, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer instead of using Equals try using Contains this should take… May 12, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer A few observations: If unique_id is really unique, then I'd… May 12, 2026 at 6:25 pm

Related Questions

I need to implement SSO between a windows domain and a J2EE web appliction.
I have a J2EE web-application running on Sun hardware with OpenSolaris/Glassfish stack. We're starting
We have a java web service application that uses log4j to do logging. An
A hobby project of mine is a Java web application. It's a simple web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.