This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "special characters" Watch "special characters" New topic

special characters

sawan parihar
Ranch Hand

Joined: Aug 24, 2004
Posts: 250
In my web application I have to remove the special characters user may enter. If the user enters any special character I want to remove it. One way I can imagine is through javascript . But this will require changing all the jsp pages which is going to be a mess. That is why I am planning to write a filter. Can anybody suggest me what is the better approach and if the filter approach is right then how can I remove the special characters in filter. . Your help is highly appreciated.



Sawan<br />SCJP,SCWCD,SCBCD<br /> <br />Every exit is an entry somewhere.
Sarath Mohan
Ranch Hand

Joined: Mar 17, 2001
Posts: 213
Filter is a good option. You can pre process request. If user enters space and space or + or & it may be sent as different characters to the server. So how do you catch the value of attribute name=first name. It will be sent as first+name. Now if user enter first na+me how do we interpret first+na+me which is coming to server?

I feel you have to user Url encoding at client and decoding at the filter in each text field user enters if java script is not viable.

Sarath Mohan
jQuery in Action, 2nd edition
subject: special characters
Similar Threads
non-printable special characters
how toremove files or directory in unix with name of special characters
How do I secure my response header from CRLF
special characters
Displaying special characters or HTML using Struts