You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Barry Draper <ba...@informix.com> on 2001/06/07 23:39:32 UTC

RE: Problem: Using Tomcat 3.2.1 on NT 4.0 SP5, get Internal Servl et E rror on writing POST response approx. > 800kb in length

You are correct. I found the problem at specified line.
I _somehow_ didn't see it until you pointed it out.
I didn't mean to improperly post. I just didn't see it.
Thanks much.
Barry

-----Original Message-----
From: William Kaufman [mailto:WKaufman@viquity.com]
Sent: Thursday, June 07, 2001 12:59 PM
To: 'tomcat-user@jakarta.apache.org'
Subject: RE: Problem: Using Tomcat 3.2.1 on NT 4.0 SP5, get Internal
Servl et E rror on writing POST response approx. > 800kb in length


> Location: /servlet/MyServlet Internal Servlet 
> Error:java.lang.ArrayIndexOutOfBoundsException: 10
>  at MyServlet.doPost(MyServlet.java:157)

This isn't a Tomcat issue: _your_ code is throwing an
ArrayOutOfBoundsException, at line 157.

Moreover, the code you posted doesn't look like it'd throw such an
exception; line 157 must be a line you didn't post.

                                                            -- Bill K.

-----Original Message-----
From: Barry Draper [mailto:barry.draper@informix.com]
Sent: Thursday, June 07, 2001 12:55 PM
To: tomcat-user@jakarta.apache.org
Subject: Problem: Using Tomcat 3.2.1 on NT 4.0 SP5, get Internal Servlet E
rror on writing POST response approx. > 800kb in length


Using Tomcat 3.2.1 on NT 4.0 SP 5, I have a servlet which sends XML-encoded
strings in response
to POST requests. When the XML -encoded response is approximately > 800
bytes in length (my test case
is 889 bytes - I don't know the exact threshold yet), I get the following
error:

Error: 500
Location: /servlet/MyServlet Internal Servlet
Error:java.lang.ArrayIndexOutOfBoundsException: 10
 at MyServlet.doPost(MyServlet.java:157)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
 at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
 at org.apache.tomcat.core.Handler.service(Handler.java:286)
 at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
 at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
 at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
 at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:210)
 at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
 at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
 at java.lang.Thread.run(Thread.java:479)


I tried increasing the ServletResponse buffer size to 64kb (the default is
8kb)
and also setting content length as follows:

public void doPost( HttpServletRequest request, HttpServletResponse
response)
                throws ServletException, IOException
{
 ...
 response.setContentType("text/plain");
 response.setBufferSize(64 * 1024);
 PrintWriter out = response.getWriter();

...
 String result = null;
 // do processing which sets result string

 int len = result.length();
 response.setContentLength(len);
...
out.println(result);

I verified that the response buffer size was increased to 64kb and the
content length was set correctly.

Still, I get the error on writing the response.

Is this a known problem with a fix? Am I doing something wrong?
Please advise.

Thanks.
Barry Draper
barry@informix.com