Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Pooja Agarwal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic