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 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

Related Questions

My requirement is I have server J2EE web application and client J2EE web application.
I have a J2EE web-application running on Sun hardware with OpenSolaris/Glassfish stack. We're starting
I have a question regarding handling errors in a J2EE application. Our current application
I have apache web server installed as frontend and I have j2ee SAP Netweaver
I have a simple j2ee application: foo.ear - foo.war - foo.jar (ejb3 jar) I
in eclipse, i have a weblogic server running, and a j2ee application deployed to
I have a J2EE project in Eclipse 3.2 and at the end of every
I have a J2EE-based system which is running currently on Apache Tomcat. We are
CFMX 8 Enterprise I have turned on the Use J2EE session variables setting under
Have just started using Google Chrome , and noticed in parts of our site,

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.