You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by elin <el...@albacore.se> on 2007/02/06 17:17:54 UTC

Struts2, tiles2 and character encoding problem

Hi,

I use struts2 and tiles2 in my web application. When my tiles result
contains data with åäö and I write the data using el, the characters are not
displayed correctly. If I write the data with a struts tag, for example
<s:property> the characters are displayed correctly.

If I do not to use a tiles result, just a simple jsp, the characters are
displayed correctly when I use el.

I have specified struts.i18n.encoding=UTF-8.

I use a CharacterEncodingFilter to set encoding to UTF-8.

I specify <meta http-equiv="content-type" content="text/html;
charset=UTF-8"/> on the page.

Any ideas?

/Elin



-- 
View this message in context: http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8828883
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2, tiles2 and character encoding problem

Posted by elin <el...@albacore.se>.
Reported bug:

https://issues.apache.org/struts/browse/TILES-104

Let's continue any further conversation on the dev@tiles mailing list.



Joe Germuska wrote:
> 
> OK, a few more notes:
> 
> just to be clear,
> 
> I have specified struts.i18n.encoding=UTF-8.
> 
> 
> This is not used to directly set the response character encoding.
> 
> I use a CharacterEncodingFilter to set encoding to UTF-8.
> 
> 
> In my experience, a CharacterEncodingFilter is used to control the request
> content type, not the response content type.  That's what the Spring class
> called CharacterEncodingFilter does.  Assuming yours is the same, it won't
> come into play in debugging this problem.
> 
> I specify <meta http-equiv="content-type" content="text/html;
>> charset=UTF-8"/> on the page.
>>
> 
> I am not sure whether browsers allow this to override an explicit content
> type set in the HTTP response, but in any case, it's more important that
> the
> HTTP response header be explicitly set.  In a local test application I
> have,
> the servlet container is setting the header even when I don't explicitly
> set
> it.
> 
> Using the latest code, I've tested going directly to a JSP (no struts),
> going to a default result (RequestDispatcher.forward) and going to a Tiles
> result.  I get an explicit content type in all three cases, even though
> the
> JSP itself doesn't set the content type. I think there's something about
> that in the Servlet spec, that the container is required to set a content
> type, although that's at odds with what I experienced when I filed
> TILES-28
> and with Elin's experience, so I'm not sure.
> 
> This discussion REALLY belongs on dev@tiles -- user lists are meant to
> discuss using the app, not fixing bugs in prereleased code.  Elin, if you
> want to pursue this, please file a bug with as much as you can offer for
> reproducibility (especially since I just tried and can't reproduce it) and
> if you want to have further email, please join the dev@tiles mailing list.
> See http://tiles.apache.org/mail-lists.html
> 
> 
> On 2/7/07, elin <el...@albacore.se> wrote:
>>
>>
>> I double-checked that there is only one tiles-core jar.
>>
>> Monitoring shows:
>>
>> Conventional Struts result response's Content-Type header is
>> text/html;charset=utf-8
>>
>> If I request a jsp directly, the response's Content-Type header is
>> text/html;charset=utf-8
>>
>> Tiles Result response has no Content-Type header
>>
>>
>>
>> Elin
>> --
>> View this message in context:
>> http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8845842
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> Joe Germuska
> Joe@Germuska.com * http://blog.germuska.com
> 
> "The truth is that we learned from João forever to be out of tune."
> -- Caetano Veloso
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8863903
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2, tiles2 and character encoding problem

Posted by Joe Germuska <jo...@germuska.com>.
OK, a few more notes:

just to be clear,

I have specified struts.i18n.encoding=UTF-8.


This is not used to directly set the response character encoding.

I use a CharacterEncodingFilter to set encoding to UTF-8.


In my experience, a CharacterEncodingFilter is used to control the request
content type, not the response content type.  That's what the Spring class
called CharacterEncodingFilter does.  Assuming yours is the same, it won't
come into play in debugging this problem.

I specify <meta http-equiv="content-type" content="text/html;
> charset=UTF-8"/> on the page.
>

I am not sure whether browsers allow this to override an explicit content
type set in the HTTP response, but in any case, it's more important that the
HTTP response header be explicitly set.  In a local test application I have,
the servlet container is setting the header even when I don't explicitly set
it.

Using the latest code, I've tested going directly to a JSP (no struts),
going to a default result (RequestDispatcher.forward) and going to a Tiles
result.  I get an explicit content type in all three cases, even though the
JSP itself doesn't set the content type. I think there's something about
that in the Servlet spec, that the container is required to set a content
type, although that's at odds with what I experienced when I filed TILES-28
and with Elin's experience, so I'm not sure.

This discussion REALLY belongs on dev@tiles -- user lists are meant to
discuss using the app, not fixing bugs in prereleased code.  Elin, if you
want to pursue this, please file a bug with as much as you can offer for
reproducibility (especially since I just tried and can't reproduce it) and
if you want to have further email, please join the dev@tiles mailing list.
See http://tiles.apache.org/mail-lists.html


On 2/7/07, elin <el...@albacore.se> wrote:
>
>
> I double-checked that there is only one tiles-core jar.
>
> Monitoring shows:
>
> Conventional Struts result response's Content-Type header is
> text/html;charset=utf-8
>
> If I request a jsp directly, the response's Content-Type header is
> text/html;charset=utf-8
>
> Tiles Result response has no Content-Type header
>
>
>
> Elin
> --
> View this message in context:
> http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8845842
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com

"The truth is that we learned from João forever to be out of tune."
-- Caetano Veloso

Re: Struts2, tiles2 and character encoding problem

Posted by elin <el...@albacore.se>.
I double-checked that there is only one tiles-core jar.

Monitoring shows:

Conventional Struts result response's Content-Type header is
text/html;charset=utf-8

If I request a jsp directly, the response's Content-Type header is
text/html;charset=utf-8

Tiles Result response has no Content-Type header



Elin
-- 
View this message in context: http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8845842
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2, tiles2 and character encoding problem

Posted by Joe Germuska <jo...@germuska.com>.
TILES-28 should be resolved in the SNAPSHOT version you indicate, while the
subsequent change (to the Taglib URI) hadn't been changed.  I just deployed
a 2.0-SNAPSHOT rather than let it hang on as something less clear going
forward.

But back to your issue: it might seem that you've found a variation of the
problem that was fixed in TILES-28  Make absolutely sure you don't have more
than one version of the tiles-core JAR in your app, but assuming that you
don't, we'll have to sniff around some more and figure out what might be
different.  You're doing the right kind of monitoring already -- what does
Fiddler say if you get a conventional Struts result
(ServletDispatcherResult) from your app?  What about if you get a JSP
directly from the app without going through Struts?



Joe

On 2/7/07, elin <el...@albacore.se> wrote:
>
>
> Thank you for your reply.
>
> I upgraded from struts 2.0.4 to 2.0.5 but with the same result. I use
> maven
> to build the project which gives me the tiles version
> tiles-core-2.0-20070130.184344-3.jar. It seems to be the latest snapshot.
> Is
> this the version where the bug you mentioned is fixed? Or do you mean that
> it is fixed in the next build?
>
> Monitoring the response with fiddler shows that there is no content-type
> header.
>
> I use a tiles definition file and the insertAttribute tag to build the
> tiles
> result.
>
> Elin
> --
> View this message in context:
> http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8841954
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com

"The truth is that we learned from João forever to be out of tune."
-- Caetano Veloso

Re: Struts2, tiles2 and character encoding problem

Posted by elin <el...@albacore.se>.
Thank you for your reply.

I upgraded from struts 2.0.4 to 2.0.5 but with the same result. I use maven
to build the project which gives me the tiles version
tiles-core-2.0-20070130.184344-3.jar. It seems to be the latest snapshot. Is
this the version where the bug you mentioned is fixed? Or do you mean that
it is fixed in the next build?

Monitoring the response with fiddler shows that there is no content-type
header.

I use a tiles definition file and the insertAttribute tag to build the tiles
result.

Elin
-- 
View this message in context: http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8841954
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts2, tiles2 and character encoding problem

Posted by Joe Germuska <jo...@germuska.com>.
Are you using the newest version of Tiles?  There was a bug in which the
content types were not being set in some cases; I was using a JSP page
attribute to set the content type, not the other options, but it may be
related.

For everyone who is using Tiles 2, note that very soon now, the SNAPSHOT
version of Tiles will be changing the URI for the TLD from
http://struts.apache.org/tags-tiles to http://tiles.apache.org/tags-tiles so
you will need to update the taglib declarations in your JSPs.  (We use a JSP
include directive like this

<%@ include file="/WEB-INF/tiles/_boilerplate.jsp" %>

so that we only have to change it in one place.  If you don't do something
like that, then I hope you have a good global search/replace option...  I
will probably build a new Maven SNAPSHOT in the next few days unless another
developer does it first.  (Note that if you're using Tiles 2, you probably
ought to monitor the dev@tiles list in case no one mentions things like this
to the Struts user list.  In general, Apache projects expect discussion of
pre-release software to occur on dev lists, not user lists.)

For reference, the bug to which I refer is
https://issues.apache.org/struts/browse/TILES-28

Joe


On 2/6/07, elin <el...@albacore.se> wrote:
>
>
> Hi,
>
> I use struts2 and tiles2 in my web application. When my tiles result
> contains data with åäö and I write the data using el, the characters are
> not
> displayed correctly. If I write the data with a struts tag, for example
> <s:property> the characters are displayed correctly.
>
> If I do not to use a tiles result, just a simple jsp, the characters are
> displayed correctly when I use el.
>
> I have specified struts.i18n.encoding=UTF-8.
>
> I use a CharacterEncodingFilter to set encoding to UTF-8.
>
> I specify <meta http-equiv="content-type" content="text/html;
> charset=UTF-8"/> on the page.
>
> Any ideas?
>
> /Elin
>
>
>
> --
> View this message in context:
> http://www.nabble.com/Struts2%2C-tiles2-and-character-encoding-problem-tf3181491.html#a8828883
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Joe Germuska
Joe@Germuska.com * http://blog.germuska.com

"The truth is that we learned from João forever to be out of tune."
-- Caetano Veloso