wood burning stoves
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Filter Non Ascii characters" Watch "Filter Non Ascii characters" New topic

Filter Non Ascii characters

Raghu Sha
Ranch Hand

Joined: Feb 02, 2013
Posts: 122

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

K. Tsang

Joined: Sep 13, 2007
Posts: 3059

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 OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
Raghu Sha
Ranch Hand

Joined: Feb 02, 2013
Posts: 122

I am using Spring MVC, do i need to write seperate filter for filtering Non Ascii characters or spring provides implementation?
I agree. Here's the link: http://aspose.com/file-tools
subject: Filter Non Ascii characters
It's not a secret anymore!