This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Parsing with DOM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing with DOM "hangs": inputstream problem" Watch "Parsing with DOM "hangs": inputstream problem" New topic
Author

Parsing with DOM "hangs": inputstream problem

J.H.B. Oosterlaar
Ranch Hand

Joined: Sep 12, 2002
Posts: 41
Hi,
We are developing a simple server that translates a XML query to a SQL query, sends that SQL query to the database, translates the result to a XML resultset and sends it back to the connecting client.
We are using DOM to interpret the XML in order to build the XML query, since DOM builds a tree (that we use as a buffer), instead of SAX that has to be interpreted realtime.
Our problem is as follows: the inputstream of the socket act as the input stream for DOM. No exception occures, but at the point when we call domParser.parse();, the thread hangs. When we close the connection, the local output (at the server) is done; the thread continues.
We assume that the following causes the problem: the inputstream is used to read the XML from. But when the XML is sent over the stream, the stream is not closed. Somehow the parser still expects something. When the clientconnection is closed, the stream is closed and the thread can continue; the parser know that the input is ended.
Do you know how to solve this? We cannot just close the connection, because we need to receive the result. Does the parser expects some end indicator? For the inputstream for the parser we use a BufferedReader (otherwise we are getting a NullPointerException).
Thanks! And cheers,
Jeroen Oosterlaar
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Sounds to me like you are not doing a flush() on the output stream that sends the query. That can cause very odd results. Also a final crlf after the closing element might be a good idea.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing with DOM "hangs": inputstream problem
 
Similar Threads
Does the order of stream closing matters?
connection can not be closed in weblogic6.1 and sql_server 2000
is Document object closes the open file
Independent Serwer to Client (!) communication
Default XML parser: SAX or DOM?