Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

<Error> <HTTP> Connection failure java.net.ProtocolException: Didn't meet stated Content-Length

13 views
Skip to first unread message

Heinrich Kislinger

unread,
Feb 20, 2002, 11:19:09 AM2/20/02
to
Hi,
while trying to make a servlet run under my evaluation version of Bea WLS6.1
I always face a problem which I don't know how to handle.

In my servlet's doPost() method, I'm writing some response data to the
client using the PrintWriter returned by HttpServletResponse.getWriter().
After finishing the servlet's doPost() method the following exception stack
trace can be seen in the console window:

============================================
<20.02.2002 17:10:37 CET> <Error> <HTTP> <Connection failure
java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '1644'
bytes instead of stated: '48' bytes.
at
weblogic.servlet.internal.ServletOutputStreamImpl.finish(ServletOutputStream
Impl.java:413)
at
weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:
974)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1964)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
<20.02.2002 17:10:37 CET> <Error> <HTTP> <Servlet execution in servlet
context "WebAppServletContext(7770340,DefaultWebApp,/DefaultWebApp)"
failed, java.net.ProtocolException: Didn't meet stated Content-Length,
wrote: '1644' bytes instead of stated: '48' bytes.
java.net.ProtocolException: Didn't meet stated Content-Length, wrote: '1644'
bytes instead of stated: '48' bytes.
at
weblogic.servlet.internal.ServletOutputStreamImpl.finish(ServletOutputStream
Impl.java:413)
at
weblogic.servlet.internal.ServletResponseImpl.send(ServletResponseImpl.java:
974)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:1964)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
============================================

Any hints would be great. Thanks in advance
Michael


Michael Wooten

unread,
Feb 20, 2002, 4:05:22 PM2/20/02
to

Hi Heinrich,

Are you returning an string containing XML? If so, you should put the following
lines at the end of the doPost():

byte[] bytes = xmlString.getBytes("UTF-8");
response.setContentLength(bytes.length);
out.println(xmlString);

I'm assuming you have already set the content type of the HttpServletResponse
to "text/xml; charset=UTF-8", as in:

response.setContentType("text/xml; charset=UTF-8");
out = response.getWriter();

Regards,
Mike Wooten

Heinrich Kislinger

unread,
Feb 21, 2002, 5:24:52 AM2/21/02
to
Hi Michael,

thank you for your reply. My servlet sends data of the mime-type
"application/octet-stream". May be the problem is related with the way I'm
using the doPost() method. After the first time a specific client connects
with my servlet, a response is sent and the doPost() method is blocked
rather than terminated. I need this behavior in order to reach the client
more than once in response to kind of randomly occurring events. This works
fine and gives me the ability to use my servlet to establish sort of HTTP
tunneling. After I find out that the work is done, the doPost() method is
simply exited. This leads to the previously described console output. Gives
me the impression that WLS tries to send a final response to the client, may
be a "HTTP ... 200 OK", and the servlet's thread environment is different
than expected!??

Thanks for any additional suggestions and ideas.
Michael

"Michael Wooten" <wooten_...@hotmail.com> wrote in message
news:3c740f92$1...@newsgroups.bea.com...

0 new messages