This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrting XML in Servlet
 
Similar Threads
XML parser to validate XML docs in my Servlet.
how to resolve the problem with Deploying this war file ?
XML b/w Servlets?
unable to remove spaces in xml
sevlet