This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Wrting XML in Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Wrting XML in Servlet" Watch "Wrting XML in Servlet" New topic
Author

Wrting XML in Servlet

Vikas
Ranch Hand

Joined: Dec 16, 2004
Posts: 63
Hi Friends,

I have a task to write an XML document in a Servlet file and sending it to the JSP. Can any one suggest how to proceed in this regards??

Thank you
Vikas
Chris Stehno
Ranch Hand

Joined: Feb 26, 2001
Posts: 180
You could generate the xml as a string or strings inside the servlet and set the content type to "text/xml" or you could build a Document object and put it in the request forwarded to the JSP page (setAttribute()) and then use the Document object directly in the JSP page.

Hope this helps.


- Chris Stehno, SCPJ
Vikas
Ranch Hand

Joined: Dec 16, 2004
Posts: 63
Thank you Chris. I am already implementing the way you suggested. My requirement is that I want to send an xml file abc.xml at client end to enable the AJAX so that the created xml files stays at the system of end user and and he/she doesn't need to hit the server again and again.

Regards
Vikas Sharda
Vikas
Ranch Hand

Joined: Dec 16, 2004
Posts: 63
HI,

Can anybody suggest me as to which approach his better one?? Is it the one that is suggested by Chris or having an XML document at end user location seperately??

Thank you
Regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Wrting XML in Servlet