Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Filter Non Ascii characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Filter Non Ascii characters" Watch "Filter Non Ascii characters" New topic
Author

Filter Non Ascii characters

Raghu Sha
Ranch Hand

Joined: Feb 02, 2013
Posts: 122
Hi,

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

Thanks,
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2242
    
    7

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.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Raghu Sha
Ranch Hand

Joined: Feb 02, 2013
Posts: 122
Thanks,

I am using Spring MVC, do i need to write seperate filter for filtering Non Ascii characters or spring provides implementation?
 
wood burning stoves
 
subject: Filter Non Ascii characters
 
Similar Threads
String Encoding
force users to use english character set
Binary files
Unable to print Swedish Character using DocFlavor
what is default value for char array?