File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Updating data from jsp pages into an xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Updating data from jsp pages into an xml file" Watch "Updating data from jsp pages into an xml file" New topic
Author

Updating data from jsp pages into an xml file

neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
Hi,

Suppose I have two jsp pages.The first jsp page contains a text box to enter name and age.On clicking the next button of 1st jsp page we move to the second jsp page
where we have textboxes to enter address informations like city,state,pin.Now on click of the submit button of 2nd jsp page i would like the data provided by user to get copied in a xml file.I will be already having a template xml file on the server.Now for each user based on this template a separate xml file should be created.How do i achieve the same using SAX Parser?
The template xml file(Scenario.xml), with default values, that will be on server will look something like this:-

Scenario.xml


Whenever a user enters his details,then based on the above template file and with the use of Sax Parser the data should be updated in a new xml file unique to that particular user .The name of the new xml file created can be kept unique by appending the sessionid to the xml file.The template xml file should remain as it is.

Kindly help as how should i go about it.

Regards.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

http://www.roseindia.net/xml/dom/CreatXMLFile.shtml


Swastik
neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
Hi,

Thanks for the reply.However i am supposed to use SAX parser ,not DOM parser.Kindly help in this regard.

Regards
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
neha priya wrote:However i am supposed to use SAX parser ,not DOM parser.

That doesn't make sense - SAX has no provisions for creating or altering XML, it is used for reading XML. You will need to use DOM (or one of its replacement libraries like XOM, JDOM, dom4j).


Ping & DNS - updated with new look and Ping home screen widget
neha priya
Ranch Hand

Joined: Jul 03, 2010
Posts: 62
Thanks for the reply.So can you please help me as how do i collect information from various jsp pages and put them in a unique xml file on the server.

Regards.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

It seems that you have already passed info from page1 to page2. When page2 is submitted, the request goes once again to your servlet. Write some helper class to deal with creation of xml file, and invoke this class from the servlet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating data from jsp pages into an xml file
 
Similar Threads
writing into xml as wells as into tables
Stopping STAX
XML vs Database
Let's discuss the sample test
Right Answer