cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@localbar.com>
Subject Re: BUG?: Writing NaN% to a ServletOutputStream
Date Mon, 13 Mar 2000 06:09:27 GMT

Looks like the PercentInstance is trying to output characters that are not
defined in the 8859-1 character set.
The missing message of the key, is a ResourceBundle thing, I guess. No text has
been defined in the resource bundle, and is not part of the actual problem.

Could you possibly capture all those characters to a string object, convert it
to an char[] and output the value of each one, to see exactly what is
happening.

The reason for JSP is working, could be things like, JSP is outputting to the
Writer instead of the Stream and there are no checks there or those characters
are filtered out.

Niclas

"Stevenson, Chris (SSABSA)" wrote:

> Using Tomcat 3.1beta1
>
> When I use a
>         NumberFormat.getPercentInstance()
> to write to a ServletOutputStream, and try to format a NaN
>         out.print("<p>" + nf.format(60.0/0) + "</p>");
> I get the following Exception:
>
> java.io.IOException: cannot find message associated with key :
> servletOutputStream.fmt.not_iso8859_1
>
> The underlying Exception seems to be stream format error, but
> this hapens ONLY if I do the call in a servlet - if it is in
> a JSP file it does not cause an error!
>
> Is this because I have not set the output encoding? or is it a
> bug?
>
> chris.
>
> -- test Servlet: Does cause Error
>
> import java.text.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class TestBug extends HttpServlet {
>     protected void doGet(HttpServletRequest request, HttpServletResponse
> resp)
>               throws ServletException, java.io.IOException {
>       ServletOutputStream out = resp.getOutputStream();
>         out.print("<html>");
>         out.print("<head>");
>         out.print("</head>");
>         out.print("<body>");
>         out.print("<p>%?</p>");
>         NumberFormat nf = NumberFormat.getPercentInstance();
>         out.print("<p>" + nf.format(60.0/0) + "</p>"); //NaN -> ?%
>         out.print("</body>");
>         out.print("</html>");
>       out.close();
>     }
> }
>
> -- test JSP: Does NOT cause error
>
> <%@ page import="java.text.NumberFormat"%>
> <p>?%</p>
> <p>
> <%
>         NumberFormat nf = NumberFormat.getPercentInstance();
>         out.print("<p>" + nf.format(60.0/0) + "</p>"); //NaN -> ?%
> %>
>
> -- Full exception
>
> Internal Servlet Error:
>
> java.io.IOException: cannot find message associated with key :
> servletOutputStream.fmt.not_iso8859_1
>         at
> org.apache.tomcat.core.BufferedServletOutputStream.print(BufferedServletOutp
> utStream.java:222)
>         at TestBug.doGet(TestBug.java:20)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:390)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:422)
>         at
> org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
>         at
> org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:390)
>         at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:523)
>         at
> org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
> onnectionHandler.java:146)
>         at
> org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:334
> )
>         at java.lang.Thread.run(Thread.java:484)
>
> -- Chris Stevenson ----------------------- SSABSA --
> Senior Secondary Assessment Board of South Australia
> 60 Greenhill Road, Wayville SA 5034, Australia
> email: chris@ssabsa.sa.gov.au
> phone: (08) 8372 7515
>   fax: (08) 8372 7590
> ----------------------------------------------------


Mime
View raw message