[jdom-interest] JDOM Closing my Servlet OutputStream
CND
admin at brevsville.com.au
Tue Feb 20 02:10:37 PST 2001
Hi.
I'm new to JDOM and new to XML so I might be missing something obvious
here.
Whenever I use the DOM/SAX parser withing my Servlet doPost or doGet
methods, the ServletOutputStream seems to get trashed. For example I use
the code below:
public void doPost(HttpServletRequest req,HttpServletResponse res){
DOMBuilder b = new DOMBuilder();
// Create the document
Document doc = b.build(req.getInputStream());
Element node = doc.getRootElement();
String bc = node.getChild("Request")
.getChild("PunchOutSetupRequest")
.getChild("BuyerCookie").getTextTrim();
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
out.println("<html>Hello!</HTML>
out.flush();
etc...
Nothing gets out of the ServletOutputStream. However if I remove the line
:
Document doc = b.build(req.getInputStream());
Everything works just fine! So clearly something is going wrong with the
"build"....or maybe my mind:)
I have tried getting the printwriter before calling "build" but to no
avail. I know the parser if working correctly since the Element text
returned is perfect. If I send my output to the servlet log, the output
is fine. I just can't get anything out of the ServletOutputStream. I used
checkError() and it returns false and the stream is open. I ran exactly
the same code against an xml file in a standard java class (not a servlet)
and it also works fine.
I'm using JDOM-b-6 and tested in Linux and W2K. I also have Jason and
Craig's Java-XML book but no clues there either.
Help!
Thanx
Chris
PS
Jason since your Servlet Programming book is so fantastic, why not a nice
XML-Servlet book?
More information about the jdom-interest
mailing list