Fwd: [jdom-interest] SAXBuilder.build() weirdness

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed Jul 18 05:06:21 PDT 2001


At 1:44 AM +0100 7/18/01, Bob Tarling wrote:
>

>Basically, as far as I can make out, the problem is that the DOM parser doesn't always know when a stream coming in through a BufferedReader has ended. If your reading a file then fine, a file has a definite end. But if your reading in through a socket it just carries on waiting while the socket is open as it doesn't know if the client has finished. ..
>
>The attached solution sends the entire XML across the socket as a single string terminated by a line break. This is then transfered to a StringReader and the StreamReader can be accepted by the build as the string has a definite end.
>

No, unless there's something weird going on with servlets specifically (Jason, comments?) this should not be the problem or the solution. When you use HTTP POST, you should always include a Content-length MIME header that specifies the exact number of bytes you're sending in the message body. Once that number of bytes as been received, the server should indicate end of stream. If you're not sending a proper content-length header field, then the client needs to close the connection so the server knows it's done. 
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      | 
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list