• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

special characters

 
sawan parihar
Ranch Hand
Posts: 250
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Thanks.

Regards,
Sawan
 
Sarath Mohan
Ranch Hand
Posts: 213
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic