• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filter Non Ascii characters

 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

How to filter Non Ascii characters from user input using web filter.
Please share the sample code.

Thanks,
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to write a CharacterEncodingFilter setting the encoding to say UTF8 for the response and request. If you are not familiar with writing a filter writing javax.servlet.filter

Remember to add this Filter to your web.xml file.
 
Raghu Sha
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I am using Spring MVC, do i need to write seperate filter for filtering Non Ascii characters or spring provides implementation?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!