You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Soefara Redzuan <so...@hotmail.com> on 2002/03/19 02:20:47 UTC

Re: Tomcat and Unicode parameters in URLs ???

>Setting the content type, as you did above, only affects the *output* of
>that particular response -- it has nothing to do with how the next *input*
>request from that browser will be handled.
>
>In order to deal with request parameters in an incoming request, you must
>tell Tomcat what encoding to use, *before* processing the parameters.
>This is done by calling the request.setCharacterEncoding() method that was
>added in Servlet 2.3.  As long as you call this before calling methods
>like request.getParameter(), the proper encoding will be applied.
>
>One way to do this without modifying your application itself is to use a
>Filter that looks at incoming requests and decides what encoding should be
>used -- perhaps by looking at the <code>Accept-Language</code> header, or
>based on attributes you have stored in the current session that indicate
>what the user will be supplying.

But what happens if you really do not know what character set to expect ? In 
our company, the webserver is used for B2B messaging with customers and not 
purely serving web pages.  For example, we can accept a message with a query 
string like this
http://vpn.ourcompany.com/servlet/incoming?company=CustomerName&referenceId=1234&noteText=

The noteText could be in one of several languages since we do international 
business. We're currently considering adding a language parameter such as 
&Language=English but it would be nicer to autodetect the language. Is this 
possible ?

Thank you, Soefara

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Tomcat and Unicode parameters in URLs ???

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Tue, 19 Mar 2002, Soefara Redzuan wrote:

> Date: Tue, 19 Mar 2002 09:20:47 +0800
> From: Soefara Redzuan <so...@hotmail.com>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: tomcat-user@jakarta.apache.org
> Subject: Re: Tomcat and Unicode parameters in URLs ???
>
>
> >Setting the content type, as you did above, only affects the *output* of
> >that particular response -- it has nothing to do with how the next *input*
> >request from that browser will be handled.
> >
> >In order to deal with request parameters in an incoming request, you must
> >tell Tomcat what encoding to use, *before* processing the parameters.
> >This is done by calling the request.setCharacterEncoding() method that was
> >added in Servlet 2.3.  As long as you call this before calling methods
> >like request.getParameter(), the proper encoding will be applied.
> >
> >One way to do this without modifying your application itself is to use a
> >Filter that looks at incoming requests and decides what encoding should be
> >used -- perhaps by looking at the <code>Accept-Language</code> header, or
> >based on attributes you have stored in the current session that indicate
> >what the user will be supplying.
>
> But what happens if you really do not know what character set to expect ? In
> our company, the webserver is used for B2B messaging with customers and not
> purely serving web pages.  For example, we can accept a message with a query
> string like this
> http://vpn.ourcompany.com/servlet/incoming?company=CustomerName&referenceId=1234&noteText=
>
> The noteText could be in one of several languages since we do international
> business. We're currently considering adding a language parameter such as
> &Language=English but it would be nicer to autodetect the language. Is this
> possible ?
>

It would be possible if the HTTP specs defined a way to tell the server
what language the HTTP URL is encoded in, and if browsers actually sent
along that indication.  Neither seems to be the case in general -- even on
a POST transaction (where the browsers really have no excuse for not
including the character encoding in the Content-Type header), many don't.
Thus, you're stuck haveing to figure it out for yourself.

Note that adding a language parameter to the query string isn't going to
do you much good -- you have to call setCharacterEncoding() *before* you
call request.getParameter(), so you won't have been able to read the
language field first.

> Thank you, Soefara
>
> _________________________________________________________________

Craig

> Join the world’s largest e-mail service with MSN Hotmail.
> http://www.hotmail.com
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>