When a certain user tries to view our web page, a NullPointerException with the message 'charsetName' is thrown when we call response.getWriter(). I decompiled our web server's response class (JRun 3.1) and found that this error is being thrown when it does this:
s = getCharacterEncoding(); // returns 'x-mac-roman' I believe
try
{
outWriter.exchangeWriter(new OutputStreamWriter(bufStream, s));
}
catch(UnsupportedEncodingException unsupportedencodingexception)
{
s = MIME2Java.convert(s); // looks like this returns null
outWriter.exchangeWriter(new OutputStreamWriter(bufStream, s)); // NPE!!!
}
I was finally able to reproduce this bug when I forced my browser to send a request header of 'Accept-Charset=x-mac-roman,utf-8', which is what the user's browser seems to do.
This is webserver code so I can't make any changes here, but this there something we can do on our end to ensure this never happens. Can we explicitly force the webserver to use a certain encoding and not leave it up to the requests?