I don't see any problem here, because ServerOutputStream is abstract class,
so a particular implementation can be quite different. For example, JWS uses
another implementation of this method. Jetty implements this method like:
    /* ------------------------------------------------------------ */
    public  void print(String string)
         throws IOException
    {
        write(string.getBytes());
    }
You can select another Java based web server or servlet engine, if you don't
like implementation of some methods.

Dmitry.
----- Original Message -----
From: Preston L. Bannister <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, September 24, 1999 9:53 PM
Subject: Unicode to UTF-8 and ServerOutputStream.print(String)


> I just about fell out of my chair when I ran across:
> ----
> public void print(String s) throws IOException {
>         if (s==null) s="null";
>         int len = s.length();
>         for (int i = 0; i < len; i++) {
>                 char c = s.charAt (i);
>
>                 //
>                 // XXX NOTE:  This is clearly incorrect for many strings,
>                 // but is the only consistent approach within the current
>                 // servlet framework.  It must suffice until servlet
output
>                 // streams properly encode their output.
>                 //
>                 if ((c & 0xff00) != 0) {        // high order byte must be
zero
>                         String errMsg =
lStrings.getString("err.not_iso8859_1");
>                         Object[] errArgs = new Object[1];
>                         errArgs[0] = new Character(c);
>                         errMsg = MessageFormat.format(errMsg, errArgs);
>                         throw new CharConversionException(errMsg);
>                 }
>                 write (c);
>         }
> }
> ----
> The above is from the ServerOutputStream class.
>
> For some reason I was expecting something like:
> ----
> public void print(String s) throws IOException {
>         writer.write((s == null) ? "null" : s);
> }
> ----
> Where "writer" was defined as (roughly):
> ----
> OutputStreamWriter writer = new OutputStreamWriter(
>         connection.getOutputStream(),
>         response.getCharacterEncoding()
>         );
> ----
>
> What am I missing???
>
>
___________________________________________________________________________
> 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
>

___________________________________________________________________________
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