| Author |
Tweak Character Encoding to UTF-8 only for one request
|
Deeps Mistry
Ranch Hand
Joined: Jan 31, 2009
Posts: 189
|
|
Hi,
I have an application with Web Work + Spring + Hibernate.
I have defined webwork.i18n.encoding=ISO8859-1 in webwork.properties file.
I chose 'ISO-8859-1' encoding because i wanted to save special characters in my database.
In one particular case, i send my request(form with hidden variables ) to a third party drafter..which has character encoding set to "UTF-8".
Now whenever i pass the request (which contains special characters) from my application to the third party, first time it shows the correct special character, but on subsequent request, it gives me a '?' or a rectangular box.
If we start a new browser instance everytime then it shows up properly.
I tried the following -
I tried to do in my filter
It does change the request encoding, till the time it calls FilterDispatcher.java where in it reads from webwork.properties and changes the character encoding back to "ISO-8895-1".
What should i do now?
Is there any way to tweak FilterDispatcher for one particular request?
Thanks.
|
 |
Mohana Rao Sv
Ranch Hand
Joined: Aug 01, 2007
Posts: 485
|
|
Imagining you were working with struts2. You can set this in struts.properties file.
if you want to override it to a particular request then you have to override FilterDispatcher(Use StrutsPrepareAndExecuteFilter).
|
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
|
 |
Deeps Mistry
Ranch Hand
Joined: Jan 31, 2009
Posts: 189
|
|
Mohana Rao Sv wrote:Imagining you were working with struts2. You can set this in struts.properties file.
if you want to override it to a particular request then you have to override FilterDispatcher(Use StrutsPrepareAndExecuteFilter).
We are using WebWorks.
I tried overriding FilterDispatcher with TestFilter.java.
In my web.xml I configured this filter for a particular request.
On request, doFilter() method of TestFilter does get called, but at the end , doFilter() method of FilterDispatcher gets called. So i end up without my encoding being changed.
Is this the right way to do it? I think I am doing something wrong.
Here is my code -
|
 |
Shankar Tanikella
Ranch Hand
Joined: Jan 30, 2011
Posts: 329
|
|
Hi Deeps,
Never worked on WebWorks. Have you seen this thread
|
Have Fun with Java
little,little.. little by little makes a lot..
|
 |
Deeps Mistry
Ranch Hand
Joined: Jan 31, 2009
Posts: 189
|
|
Shankar Tanikella wrote:Hi Deeps,
Never worked on WebWorks. Have you seen this thread
Thanks for your quick reply.
In my case , it is reading webwork.i18n.encoding=ISO8859-1 in the FilterDispatcher.java.
I want it to bypass it for one particular request.
Thanks.
|
 |
 |
|
|
subject: Tweak Character Encoding to UTF-8 only for one request
|
|
|