This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes xm file as input for servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "xm file as input for servlet" Watch "xm file as input for servlet" New topic
Author

xm file as input for servlet

Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
Hi,

How can I read a simple xml file using a servlet? Mean while I do some google search if I can find some hints..


Best Regards
Ayub


SCEA part I,TOGAF Foundation
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Read from where , from client or from server itself?


Rahul Bhattacharjee
LinkedIn - Blog
Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
Hi Rahul,

XM file needs to be read from the client as an input stream. I need to genereate back an xml document. I am not sure what processing needs to be done. If I know how to read xml and generate the same xml back, I am good with it. Any useful links on this can be useful.

Thank you.

Best Regards
Ayub.
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
We are using XStream, DomDriver from thoughtworks xstream, a Java library to serialize/deserialize objects to/from XML.

You can find that here
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Still I do not know about the client you are taking about.
If that is browser , you can use

<input type="file" name="fileName"/>

and at the server you can use fileUploader.
http://faq.javaranch.com/view?FileUpload
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12755
    
    5
How about working through the Sun tutorial on XML processing.

Creating a Document object from any InputStream is pretty simple, here is an example:

Ayub ali khan
Ranch Hand

Joined: Oct 20, 2005
Posts: 380
    
    2
Hi William,

Thanks for a cool code and the link !! While I was searching for info on XML I cam across the JDOM parser. I need some inputs on this, will post the query in the XML forum.

Thanks for your wonderful answer!!

Best Regards
Ayub.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: xm file as input for servlet
 
Similar Threads
Can we use a xml file to configure a servlet?
Servlet listening for a file on the file system
How to access string resources (.properties entries) from inside a servlet ?
Compile Servlet File Online
file upload from servlet