Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Encoding problem

 
Raycho Belchilov
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved the problem by removing the filter and changing the encoding in jsp to utf8.

The filter is not necessary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic