wood burning stoves 2.0*
The moose likes Servlets and the fly likes send a xml file to servlet and servlet send back the xml file 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 » Java » Servlets
Bookmark "send a xml file to servlet and servlet send back the xml file" Watch "send a xml file to servlet and servlet send back the xml file" New topic
Author

send a xml file to servlet and servlet send back the xml file

Pooja Agarwal
Ranch Hand

Joined: May 19, 2004
Posts: 37
hai can u help me

i have seen the code to send the text string to servlet and servlet reads it can u help me to have a example to send a xml file to servlet and servlet send back the xml file to the client,( there is no user interface).

please its urgent
Thanks in advance
Pooja.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
No understood the problem exactly. explain

How do you want to send XML to servlet? in a file or something else?
and how do the servlet send XML to client?
jai gurudev
Greenhorn

Joined: May 28, 2004
Posts: 20
Originally posted by Pooja Agarwal:
hai can u help me

i have seen the code to send the text string to servlet and servlet reads it can u help me to have a example to send a xml file to servlet and servlet send back the xml file to the client,( there is no user interface).

please its urgent
Thanks in advance
Pooja.



hi pooja

i worked in this..

the flow is like

when i sending the xml request we should marshal the request xml as object and in respons unmarhal the request object and it give it as xml.for parsing the request u can use any parser i used JDOM parser which it read element by element and parsed it.

request:
Element rootElement = requestDoc.getRootElement();
sessionId = rootElement.getAttributeValue("sessionId");
Element header = rootElement.getChild("header");
id = JDOMUtil.getString(header, "id", true, "CHECK ID");


in between u should writee code for processing and parsing
in respone:
XMLBuilder xml = new XMLBuilder();
xml.addSchema("");
xml.startChildWithAttribute("your response", "id", req.getID());
xml.startChild("header");
xml.endChild("status");
xml.endChild("header");
xml.startChild("body");

thanks

mail me if u want further answer

jaigurudev
jai gurudev
Greenhorn

Joined: May 28, 2004
Posts: 20
hi pooja

i worked in this..

the flow is like

when i sending the xml request we should marshal the request xml as object and in respons unmarhal the request object and it give it as xml.for parsing the request u can use any parser i used JDOM parser which it read element by element and parsed it.

request:
Element rootElement = requestDoc.getRootElement();
sessionId = rootElement.getAttributeValue("sessionId");
Element header = rootElement.getChild("header");
id = JDOMUtil.getString(header, "id", true, "CHECK ID");


in between u should writee code for processing and parsing
in respone:
XMLBuilder xml = new XMLBuilder();
xml.addSchema("");
xml.startChildWithAttribute("your response", "id", req.getID());
xml.startChild("header");
xml.endChild("status");
xml.endChild("header");
xml.startChild("body");

thanks

mail me if u want further answer

jaigurudev
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: send a xml file to servlet and servlet send back the xml file
 
Similar Threads
XML data send to servlet
Sending and receiving xml data
XML and Database save
Need Help with HTTP Request
Two requests in one doPost method, can this happen? Please I need help