File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Read XML file in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Read XML file in a servlet" Watch "Read XML file in a servlet" New topic

Read XML file in a servlet

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238

I want to read xml file in a servlet as part of a HTTP post request. How do I do this. Am I going to use request.getInputStream() to read data or what. Is that possible to read the file as a file or may be separate elements.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

May be this will help

If it is part of body there is no need to create a file.

dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
You can pass this stream in InputSource of XML parser. It works like a charm.

Tough in space?, <a href="" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="" target="_blank" rel="nofollow">Check it here.</a><br /><a href="" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
I agree. Here's the link:
subject: Read XML file in a servlet
It's not a secret anymore!