Re: Servlet question

At Fri, 19 Oct 2001 09:28:43 +0530,
souravm <souravm@infy.com> wrote:
> Servlet engine uses platform's default encoding while returning the
> string as a result of getParameter method call. Servlet engine converts
> the bytes based on the platforms's default encoding and creates an
> unicode string. Is there any way one can specify which is the encoding
> to be used instead of default platform's encoding ?

It depends on the servlet implementation. Weblogic allows you to set
the encoding to be used. I'm sure there are other servlet engines that
can do this.

> Same thing is done (i.e., uses platforms's default encoding) when
> servlet engine converts a unicode string to non unicode bytes while
> sending the output to the client, if the charset is sepcified using
> meta-tag instead of setting through the content type. Can the encoding
> to be used be specified someway in this case also ?

Call ServletResponse#setContentType("text/html; charset=your_encoding")
before calling ServletResponse#getWriter().

-----------------
Shigemichi Yazawa
yazawa@globalsight.com

Received on Friday, 19 October 2001 00:20:53 UTC