W3C home > Mailing lists > Public > www-jigsaw@w3.org > July to August 1998

Re: getCharacterEncoding problem

From: Yves Lafon <ylafon@w3.org>
Date: Fri, 21 Aug 1998 11:32:43 +0200 (MET DST)
To: "Skorupa, Grzegorz" <gs@inwar.com.pl>
cc: "'www-jigsaw@w3.org'" <www-jigsaw@w3.org>
Message-ID: <Pine.GSO.4.02.9808211126320.12739-100000@tarantula.inria.fr>
On Thu, 20 Aug 1998, Skorupa, Grzegorz wrote:

> Hello!
> 
> I've created a servlet with doPost method:
> 
>   public void doPost(HttpServletRequest req, HttpServletResponse res)
> 	  throws ServletException, IOException
>   {
> 
>     System.out.println(req.getCharacterEncoding());
>     ...
>   }
> 
> I invoke this servlet from html page (including a form with POST action)
> with
> 
> <meta http-equiv="Content-Type"
> content="text/html; charset=iso-8859-2">
> 
> in it's header.
> 
> And getCharacterEncoding() always returns "ISO-8859-1".
> 
> I don't know what's going. Please help!

Well, there is no http headers containing the right character encoding.
Your trick to set the character encoding rely on the fact that a specific
browser will parse the HTML and use it as a fake HTTP header. 
For your servlet, the character encoding field has to be present as a real
http header.
Regards,
k

      /\          - Yves Lafon - World Wide Web Consortium - 
  /\ /  \        Architecture Domain - Jigsaw Activity Leader
 /  \    \/\    
/    \   /  \   http://www.w3.org/People/Lafon - ylafon@w3.org    
Received on Friday, 21 August 1998 05:33:05 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:28 GMT