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.
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: 35241
7
posted
0
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).
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.