[jdom-interest] SAXBuilder.build() second try

John Muhlestein jmuhlestein at i-link.net
Fri Jul 20 08:36:22 PDT 2001

Thank you so much for sending me some code that has worked for you before.
I was wondering if you happened to notice any problems in the class that
calls the servlet.  The JDOM Document still does not appear to be building
and I get the following error in the calling program:

java.io.FileNotFoundException: http://devboard/xml/servlet/whlsl 	at
.java:545) 	at

my debug code is showing that the servlet is getting to the
SAXBuilder().build(in) code but not beyond that point.  
I want to apologize if this is starting to get too far off topic.

thanks again for the help,


-----Original Message-----
From: Joseph Bowbeer [mailto:jozart at csi.com]
Sent: Friday, July 20, 2001 6:52 AM
To: jdom-interest at jdom.org
Cc: jmuhlestein at i-link.net
Subject: [jdom-interest] SAXBuilder.build() second try

If your problem is that closing the input stream is closing the socket, then
your code isn't going to fix this: BufferedReader.close() closes the
unbuffered stream, putting you right back where you started.

Also, it doesn't look like you're making use of the content-length provided.

The following has always worked for me:

    byte[] buf = new byte[request.getContentLength()];
    new DataInputStream(request.getInputStream()).readFully(buf);
    InputStream in = new ByteArrayInputStream(buf);
    Document doc = new SAXBuilder().build(in);

----- original message -----
From: John Muhlestein jmuhlestein at i-link.net
Date: Thu, 19 Jul 2001 16:32:34 -0600

I have gone through and done what I thought would be a similar wrapper to
what is described in the FAQ for sockets to get my servlet to work and I
still seem to be hanging on the build process.

Here is the code in my servlet that I try to build my document with.
    BufferedReader br = request.getReader();
    char[] xml = new char[8000];
    CharArrayReader reader = new CharArrayReader(xml);

    SAXBuilder builder = new SAXBuilder(true);
    Document doc = builder.build(reader);

If I view the value of the array "xml" it contains my entire document that I
am POSTing to the servlet.  I am including the .java file that represents
the class I use to send data to the servlet.

I would think passing xml to a servlet would be pretty common and I'm just
missing something simple.  Just for the record again, I am using jdom-b7
from cvs 3 days ago and Tomcat 3.2 as my servlet container with my
application built into it's own context.

thanks again,


To control your jdom-interest membership:

More information about the jdom-interest mailing list