Vika Pobilytza wrote:
>
> Hi all.
> Could anyone tell me,  where am I wrong here:
>
> I try convert output default content to Cp1251  using the next
>  PrintWriter out = new PrintWriter(
>                       new OutputStreamWriter(res.getOutputStream(),
> "Cp1251"),
>                       true);
> where res is HttpServletResponse.
>
> But during run time I got this error:
> java.lang.IllegalStateException: can't mix text and binary input

Some other code processing this request has already used res.getWriter,
so this exception is thrown when you then try to get the output stream;
you can only use or the other on the same response object. If the code
above is in a servlet invoked through SSI, "some other code" can be
the SSI servlet that calls your servlet.

So try this instead:

  res.setContentType("text/html;charset=CP1251");
  PrintWriter out = res.getWriter();

Note that you need to set the content type before you call getWriter,
so that the PrintWriter is created with the character set you need.

--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to