I am interested in creating a web app that uses JSP, Servlets and XML.
At the moment I have the following:
JSP – Form input.
Servlet – Retrieving Form data and sending that data to a java object.
Java object (1) – Converts data into XML file….instantiates java object (2).
Java object (2) – Sends that file to a database.
On the returning side the database will send back another XML file that I will then process using XSLT to display back to the user.
Can I place that XSLT code in the orignial Servlets doPost() method? So my doPost()` method would:
-
Retrieve user inputted data from the form on my
JSP page. -
Instantiate a
java objectto convert that data toXML, in-turn thatobjectwill instantiates anotherobjectto send theXML fileto adatabase. -
Converts the resulting
XML filesent from thedatabaseand displays it for the user.
Can one servlet doPost() method handle all of this? If not, how would I set up my application and classes to handle this work flow?
Thank you in advance
All your
doPost()method has to do is generate a suitable servlet response (some form of content, and a suitable HTTP response structure). So it can do anything you want (including the above).However it sounds like your rendering requirement is distinct from your form submission and storage requirement. So I would make your
doPost()method delegate to a suitable method for rendering the output. That way you can generate output from stored data separately from submitting data to the database.