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 Struts and the fly likes Encoding problem 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 » Frameworks » Struts
Bookmark "Encoding problem" Watch "Encoding problem" New topic
Author

Encoding problem

Raycho Belchilov
Greenhorn

Joined: Mar 24, 2012
Posts: 7
Hi,

I am working on my first struts application and I have a problem with the encoding of Cyrillic characters. Strings of Cyrillic characters do not get passed correctly to the fields of the action class. They turn into strings of question marks.

At the top of my jsp files I have:

I am using a charset filter:

And in web.xml:

The same filter works fine in another application that is not implemented with struts. Is there anything else specific for struts that I should do?

Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Raycho,
Which version of struts are you using. Also provide when it is not working, an example. Have you checked if the filter is being executed?


Have Fun with Java
little,little.. little by little makes a lot..
Shankar Tanikella
Ranch Hand

Joined: Jan 30, 2011
Posts: 329

Hi Raycho,
Which version of struts are you using. When is this failing, an example. Have you checked if the filter is being called and executed?
Raycho Belchilov
Greenhorn

Joined: Mar 24, 2012
Posts: 7
I am using struts-2.3.1.2.

Here is the code in page1.jsp:

In struts.xml:

Here is the action class:

So I enter some Cyrillic characters in the field on page1.jsp and I submit the form. I get redirected back to the same page but instead of the characters that I had entered in the field I see question marks. There are question marks printed in the console as well (because of the System.out.println(...) statement in method "register()").

I checked the filter, it gets executed.
Raycho Belchilov
Greenhorn

Joined: Mar 24, 2012
Posts: 7
I solved the problem by removing the filter and changing the encoding in jsp to utf8.

The filter is not necessary.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Encoding problem
 
Similar Threads
Struts1+Hibernate+Tomcat and encoding problem
servlet generating big xml give me a java.lang.IllegalStateException
Tomcat file upload, UTF-8 and Linux
UTF-8 encoding problem
Locale problem in struts 1.1