• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet,Xml: How to use servletInputStream for parsing xml?

 
A Sam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Xerces for parsing xml data send by a servlet.
I did
>>>>>>>>>>>>>>>>
javax.servlet.ServletInputStream servletInputStream = HttpServletRequest.getInputStream();
org.xml.sax.InputSource inputSource = new org.xml.sax.InputSource(servletInputStream);
DOMParser parser = new DOMParser();
parser.parse(inputSource);
>>>>>>>>>>>>>
It seems that the outputstream is closed by the Xerces parser.
Could some one know any work around?
An example code would be helpful
Thanks
-Sam :roll:
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to prevent the input stream from getting closed, you could derive your own input stream class that passes all method calls except close through to a wrapped ServletInputStream.
Bill
 
A Sam
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I use JAXP for xml processing will it also close the inputstream?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what the behaviour of JAXP parsers with respect to closing the input stream is. How does closing the input stream create a problem?
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!