Re: How to set charset UTF-8

2003-08-22 Thread Billy Ng
You know what, I was using the template.  As long as I added

<% request.setCharacterEncoding("UTF-8"); %>

in the template.  It works now.

Thanks everybody

Billy Ng

This mailbox protected from junk email by Matador
from MailFrontier, Inc. http://info.mailfrontier.com

- Original Message - 
From: "Jing Zhou" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 11:15 PM
Subject: Re: How to set charset UTF-8


> We got a similar problem. At the very beginning, it looks like the
> processContent() method in the request processor would do
> the job for you if the ControllerConfig is set correctly. But the
> story is more complicated than I thought.
>
> It looks to me the container has the right to override the content
> type and/or the character encoding. From the JSP Specification,
> we have some statements like "A JSP container may use some
> implementation-dependent heuristics and/or structure to
> determine what the expected character encoding of a JSP page is..."
>
> The default implementations from Tomcat, OC4J, and SunOne are different.
> 
>
> is used in every JSP page. The Tomcat 4.1.24 generates a statement
> setContentType("text/html;charset=ISO-8859-1"); // good
> The OC4J 9.0.3 generates the statement
> setContentType("text/html;charset=UTF-8"); // something not expected
> The SunOne App7 generates the statement
> setContentType("text/html"); // something shorter with warning message.
> The Resin 2.1.10 does the same as SunOne but without warning message.
>
> I am not sure what we are missing here. Anyway, we could not *force* them
> to produce the expected content type and the character encoding
> except on Tomcat.
>
> Jing
> Netspread Carrier
> http://www.netspread.com
>
>
>
>
> - Original Message - 
> From: "Van Riper, Mike" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Cc: "'Billy Ng'" <[EMAIL PROTECTED]>
> Sent: Thursday, August 21, 2003 4:30 PM
> Subject: RE: How to set charset UTF-8
>
>
> > > I added the following to test what encoding my Struts app is using
> > >
> > > <%
> > >response.setContentType("text/html; charset=UTF-8");
> > >System.out.println(response.getCharacterEncoding());
> > > %>
> > >
> > > But it still print out the "ISO-8859-1", why?  How can I set
> > > the contentType to "text/html; charset=UTF-8"
> >
> > This is just a hunch, but, I suspect you can't change the character
> encoding
> > after you have started writing content to the stream. In that case, your
> > best bet is to do this at the very top of the JSP page:
> >
> >  <%@ page contentType="text/html;charset=UTF-8" language="java" %>
> >
> > Also, there is another consideration if you are using Tiles. Again this
is
> > just a hunch, but, I suspect that you would have to have that directive
as
> > the first line of your Tiles master layout template JSP. The concept
> > mentioned above for a single page applies to a Tiles page generated
> > dynamically from multiple JSPs all writing to the same response stream.
> >
> > We ran into something like this using the Struts template custom tags
with
> > Struts 1.0 back in 2001. We were correctly setting the character
encoding
> > using the page directive on individual content JSPs, but, had left it
off
> > our master page layout template JSP. So, it never took until we tracked
> that
> > down. Duh!
> >
> > Hope this helps, Van
> >
> > Mike Van Riper
> > mailto:[EMAIL PROTECTED]
> > http://www.baychi.org/bof/struts
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to set charset UTF-8

2003-08-22 Thread David Sperling
If you want to have both the content type and the encoding set to utf-8
with just one jsp page 
tag you can use the encoding filter found in Tomcat
4.1/webapps/test/WEB-INF/classes/filters
I think it's called "SetCharacterEncodingFilter.java".  

Do a google search to find more details on adding it to your web.xml.  



Cheers,

David Sperling

-Original Message-
From: struts [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 22, 2003 4:44 AM
To: 'Struts Users Mailing List'; 'Billy Ng'
Subject: RE: How to set charset UTF-8


Did you try <% request.setCharacterEncoding("UTF-8"); %>  ?

-Original Message-
From: Billy Ng [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 21, 2003 4:14 PM
To: Struts Users Mailing List
Subject: How to set charset UTF-8


Hi folks,

I added the following to test what encoding my Struts app is using

<%  
   response.setContentType("text/html; charset=UTF-8");
   System.out.println(response.getCharacterEncoding());
%>

But it still print out the "ISO-8859-1", why?  How can I set the
contentType to "text/html; charset=UTF-8"

Thanks!

Billy Ng


This mailbox protected from junk email by Matador
from MailFrontier, Inc. http://info.mailfrontier.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to set charset UTF-8

2003-08-22 Thread Jing Zhou
We got a similar problem. At the very beginning, it looks like the
processContent() method in the request processor would do
the job for you if the ControllerConfig is set correctly. But the
story is more complicated than I thought.

It looks to me the container has the right to override the content
type and/or the character encoding. From the JSP Specification,
we have some statements like "A JSP container may use some
implementation-dependent heuristics and/or structure to
determine what the expected character encoding of a JSP page is..."

The default implementations from Tomcat, OC4J, and SunOne are different.


is used in every JSP page. The Tomcat 4.1.24 generates a statement
setContentType("text/html;charset=ISO-8859-1"); // good
The OC4J 9.0.3 generates the statement
setContentType("text/html;charset=UTF-8"); // something not expected
The SunOne App7 generates the statement
setContentType("text/html"); // something shorter with warning message.
The Resin 2.1.10 does the same as SunOne but without warning message.

I am not sure what we are missing here. Anyway, we could not *force* them
to produce the expected content type and the character encoding
except on Tomcat.

Jing
Netspread Carrier
http://www.netspread.com




- Original Message - 
From: "Van Riper, Mike" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Cc: "'Billy Ng'" <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 4:30 PM
Subject: RE: How to set charset UTF-8


> > I added the following to test what encoding my Struts app is using
> >
> > <%
> >response.setContentType("text/html; charset=UTF-8");
> >System.out.println(response.getCharacterEncoding());
> > %>
> >
> > But it still print out the "ISO-8859-1", why?  How can I set
> > the contentType to "text/html; charset=UTF-8"
>
> This is just a hunch, but, I suspect you can't change the character
encoding
> after you have started writing content to the stream. In that case, your
> best bet is to do this at the very top of the JSP page:
>
>  <%@ page contentType="text/html;charset=UTF-8" language="java" %>
>
> Also, there is another consideration if you are using Tiles. Again this is
> just a hunch, but, I suspect that you would have to have that directive as
> the first line of your Tiles master layout template JSP. The concept
> mentioned above for a single page applies to a Tiles page generated
> dynamically from multiple JSPs all writing to the same response stream.
>
> We ran into something like this using the Struts template custom tags with
> Struts 1.0 back in 2001. We were correctly setting the character encoding
> using the page directive on individual content JSPs, but, had left it off
> our master page layout template JSP. So, it never took until we tracked
that
> down. Duh!
>
> Hope this helps, Van
>
> Mike Van Riper
> mailto:[EMAIL PROTECTED]
> http://www.baychi.org/bof/struts
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to set charset UTF-8

2003-08-21 Thread Van Riper, Mike
> I added the following to test what encoding my Struts app is using
> 
> <%  
>response.setContentType("text/html; charset=UTF-8");
>System.out.println(response.getCharacterEncoding());
> %>
> 
> But it still print out the "ISO-8859-1", why?  How can I set 
> the contentType to "text/html; charset=UTF-8"

This is just a hunch, but, I suspect you can't change the character encoding
after you have started writing content to the stream. In that case, your
best bet is to do this at the very top of the JSP page:

 <%@ page contentType="text/html;charset=UTF-8" language="java" %>

Also, there is another consideration if you are using Tiles. Again this is
just a hunch, but, I suspect that you would have to have that directive as
the first line of your Tiles master layout template JSP. The concept
mentioned above for a single page applies to a Tiles page generated
dynamically from multiple JSPs all writing to the same response stream.

We ran into something like this using the Struts template custom tags with
Struts 1.0 back in 2001. We were correctly setting the character encoding
using the page directive on individual content JSPs, but, had left it off
our master page layout template JSP. So, it never took until we tracked that
down. Duh!

Hope this helps, Van

Mike Van Riper
mailto:[EMAIL PROTECTED]
http://www.baychi.org/bof/struts


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to set charset UTF-8

2003-08-21 Thread struts
Did you try <% request.setCharacterEncoding("UTF-8"); %>  ?

-Original Message-
From: Billy Ng [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 21, 2003 4:14 PM
To: Struts Users Mailing List
Subject: How to set charset UTF-8


Hi folks,

I added the following to test what encoding my Struts app is using

<%  
   response.setContentType("text/html; charset=UTF-8");
   System.out.println(response.getCharacterEncoding());
%>

But it still print out the "ISO-8859-1", why?  How can I set the
contentType to "text/html; charset=UTF-8"

Thanks!

Billy Ng


This mailbox protected from junk email by Matador
from MailFrontier, Inc. http://info.mailfrontier.com



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



How to set charset UTF-8

2003-08-21 Thread Billy Ng
Hi folks,

I added the following to test what encoding my Struts app is using

<%  
   response.setContentType("text/html; charset=UTF-8");
   System.out.println(response.getCharacterEncoding());
%>

But it still print out the "ISO-8859-1", why?  How can I set the contentType to 
"text/html; charset=UTF-8"

Thanks!

Billy Ng


This mailbox protected from junk email by Matador
from MailFrontier, Inc. http://info.mailfrontier.com