aspose file tools*
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 Spring in Action this week in the Spring 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Encoding problem