You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jeffrey Winter <je...@attbi.com> on 2003/01/11 02:15:12 UTC

[Fatal Error] :-1:-1: Premature end of file.

I am getting a Fatal Error when POSTing, but not PUTing,
some XML data to my servlet.

In the Command Window the following is shown:

   "[Fatal Error] :-1:-1: Premature end of file."

I also print out the Exception that I caught:

   Error: org.xml.sax.SAXParseException: Premature end of file.

This occurs when attempting to parse some XML
data that I have POSTed to the servlet in its doPost() method.  
The relavent code is here:

   // stream of posted entity
   InputStream istream = req.getInputStream();

   // parse the supplied document
   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
   DocumentBuilder builder = factory.newDocumentBuilder();   
   // Exception thrown during this call
   Document inputDocument = builder.parse(istream);  


If I instead PUT the same data to the doPut() method, which
does nothing but call doPost(), the method works without a 
problem.


Here are the headers and the test XML entity that are sent with the 
XML document for the POST and the PUT.  You can see that they are 
the exact same except for the method.

   POST /myservlet?name=xxx HTTP/1.1
   Authorization: Basic d2ludGVyOndpbnRlcg==
   User-Agent: curl/7.9.5 (win32) libcurl 7.9.5
   Host: localhost:8080
   Pragma: no-cache
   Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
   Content-Length: 235
   Content-Type: application/x-www-form-urlencoded

   <test/>



   PUT /bookmarks/rest/?user=winter HTTP/1.1
   Authorization: Basic d2ludGVyOndpbnRlcg==
   User-Agent: curl/7.9.5 (win32) libcurl 7.9.5
   Host: localhost:8080
   Pragma: no-cache
   Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
   Content-Length: 235
   Content-Type: application/x-www-form-urlencoded

   <test/>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Fatal Error] :-1:-1: Premature end of file.

Posted by Jeffrey Winter <je...@attbi.com>.
Yikes,

Almost the exact second I hit "send" on my last message, I realized that the
issue is probably the Content-Type, and in fact, changing the request header
to

    Content-Type:text/xml

caused the issue with POST to go away completely and my app functions
fine.

My only remaining question is: why is the processing any different with PUT?

Has anyone experienced a similar issue?

Thanks


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>