Hi all,

I have recently ran into a problem, which at least on the surface seems a bit 
strange. First the background. The Struts 2 -based application in question has 
the following kind of guard for losing data due to session timeout. If a user 
tries to submit a form after session timeout, the application forwards the user 
to a relogin page. The relogin page forwards (almost) all parameters that it 
received to another page that then automatically (using Javascript) calls the 
original action by submitting a form with hidden parameters that convey all 
parameters that the original form had submitted.

This works fine except for a strange(?) problem regarding character encoding. 
If the submitted form contains special characters, such as ö or ä, 
the final action receives them in garbled form. I have checked that these 
characters are still html-encoded on the forwarding page itself, for example 
the raw html-code of the last form on the auto-forwarding page might look like 
this:

<form action=”/App/saveText.action" method=post">
  <input type="hidden" name="text" value="&lt;p&gt;K&ouml;ln&lt;/p&gt;" />
  <input type="submit" value="Forward" />
</form>

When this form is submitted, the action saveText receives the parameter ”text” 
in garbled (not correct UTF-8) form.

However, if there is no timeout and I look at the raw html-code of the original 
form, the code might look like this:

<form action=”/App/saveText.action" method="post">
  <textarea name="text">&lt;p&gt;K&ouml;ln&lt;/p&gt;</textarea>
  <input type="submit" value="Save" />
</form>

When this form is submitted (and there is no session timeout), the action 
saveText receives the text as correct UTF-8. The two forms and their contents 
seem identical except that in the first case the text is in a hidden field 
whereas in the latter case it is in a textarea. Why does the action saveText 
receive the data garbled in one case and ok in the other? Aren’t both types of 
input fields handled in the same way by the Struts 2 framework? How could I fix 
this problem?

Best regards,
Heikki
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to