You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robert Bowen <ro...@mubimedia.com> on 2003/03/13 16:11:38 UTC

struts include tag "broken"?

This is exactly what's tripping me up, I think! I am trying to include a
page, using the struts <include> tag, of a struts forward, but the included
page is displayed incorrectly; all the accented and "strange" characters
show up as question marks.

After struggling with the setLocale(), setContentType(), and
setCharacterEndoing() methods of the request and response objects, trying to
use the page directive and meta-tag for content at the jsp level, installing
filters at the web.xml level, defining character set environment variables
for the user that launches Tomcat, and trying every other scrap of code I
found on the net (including
String(request.getParameter().getBytes("8859_1"), "UTF-8")) I have given up!
Nothing I do changes anything! The included page will NOT display accented
characters. This same page, however, when not "included", is displayed
correctly.

So I was looking at the struts source code wondering how the include tag
works (at least in 1.1), when I saw the following line:

InputStreamReader in = new InputStreamReader(is); // FIXME - encoding

It turns out that there 4 constructors for InputStreamReader, one of which
accepts as a parameter a character set! But struts uses the default
constructor which (I imagine) creates an InputStreamReader using the default
character set of either the machine or the session.(BTW, everything works
fine in Windows, it's when I port the app to Linux, which has the american
character set as its default, that I start to have problems ...)

Could this be the answer I am looking for? What especially interests me is
the "// FIXME - encoding" comment. Does this mean what I think it does, that
someone is aware that this should be changed, that you should be able to
pass the character set parameter?

I hope so! In the mean time I have decided to make the change myself,
compile and create a new struts jar file to see if it works. I don't like
the idea of tinkering with struts source code but I am past desperation!

If anyone knows anything about this issue I would cede you my first born to
know how else it can be resolved. Incidentally, this is NOT a db issue! As I
said, the page generated by the struts forward is displayed correctly, both
dynamic content from the db as well as static content.

I'll keep the list informed of my progress.

Thanks to all,
Bob




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


Re: struts include tag "broken"?

Posted by Ferran Parra <fe...@mubimedia.com>.
Yup. That did it. I am going to do more tests, at the server and session
level, to see if I can get Tomcat to grab the character set from the user
that launches Tomcat.

But for the time being, changing:

InputStreamReader in = new InputStreamReader(is);

... to:

InputStreamReader in = new InputStreamReader(is,"ISO-8859-1");

... does the trick.

I feel like I have tempted the Gods of Struts!
-Bob

----- Original Message -----
From: "Robert Bowen" <ro...@mubimedia.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, March 13, 2003 4:11 PM
Subject: struts include tag "broken"?


> This is exactly what's tripping me up, I think! I am trying to include a
> page, using the struts <include> tag, of a struts forward, but the
included
> page is displayed incorrectly; all the accented and "strange" characters
> show up as question marks.
>
> After struggling with the setLocale(), setContentType(), and
> setCharacterEndoing() methods of the request and response objects, trying
to
> use the page directive and meta-tag for content at the jsp level,
installing
> filters at the web.xml level, defining character set environment variables
> for the user that launches Tomcat, and trying every other scrap of code I
> found on the net (including
> String(request.getParameter().getBytes("8859_1"), "UTF-8")) I have given
up!
> Nothing I do changes anything! The included page will NOT display accented
> characters. This same page, however, when not "included", is displayed
> correctly.
>
> So I was looking at the struts source code wondering how the include tag
> works (at least in 1.1), when I saw the following line:
>
> InputStreamReader in = new InputStreamReader(is); // FIXME - encoding
>
> It turns out that there 4 constructors for InputStreamReader, one of which
> accepts as a parameter a character set! But struts uses the default
> constructor which (I imagine) creates an InputStreamReader using the
default
> character set of either the machine or the session.(BTW, everything works
> fine in Windows, it's when I port the app to Linux, which has the american
> character set as its default, that I start to have problems ...)
>
> Could this be the answer I am looking for? What especially interests me is
> the "// FIXME - encoding" comment. Does this mean what I think it does,
that
> someone is aware that this should be changed, that you should be able to
> pass the character set parameter?
>
> I hope so! In the mean time I have decided to make the change myself,
> compile and create a new struts jar file to see if it works. I don't like
> the idea of tinkering with struts source code but I am past desperation!
>
> If anyone knows anything about this issue I would cede you my first born
to
> know how else it can be resolved. Incidentally, this is NOT a db issue! As
I
> said, the page generated by the struts forward is displayed correctly,
both
> dynamic content from the db as well as static content.
>
> I'll keep the list informed of my progress.
>
> Thanks to all,
> Bob
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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