JSP web app
I am interested in creating a simple web application that will take in user input, convert it to an XML file and send the file to a database.
Coding wise I feel I am okay, it is just the general setup and what implementation to use I am a bit unsure of.
At the moment I have a JSP page containing a form, the user fills out the form and on submit a POST method is sent to a servlet, in the servlet doPost() method the servlet is instantiating a java object and passing it the user inputted data. The java object then writes that data to an XML file and sends it to the database via REST.
All I would be interested to know is if this the standard/optimal way of creating such a web application.
Any and all feedback is appreciated.
There are many frameworks out there that will offer some kind of
html form->java bean-> xml file mapping
like 'Devsphere Mapping Framework'
Also there are many APIs and parsers for XML in java: SAX, DOM, JAXP, JDOM, dom4j...
I always prefer working with no frameworks at the start,
later if there is a real need for this
you can find one that meets you needs best.
Be sure you avoid scriplets in your JSP,
that you don't call DB directly from servlet,
create some XML utility creator class,
and class that works with DB,
so just split responsibilities among classes so each class has a simple one.
Here is a link for xml library i recently found it is extremely easy and fast
to work with java objects and xml files so i recommend you try it:
XStream - Two Minute Tutorial
And here is some online tool for playing with
html form to XML conversion while you are developing early version:
Transformation between HTML form and XML data
Thank you for your response, it was very helpful indeed :)
I have plans to use a framework once I get everything in order...
Here is what I have so far:
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 look something like :
//take in input
//instantiate object to convert data to xml
//convert the resulting xml file from the database via XSLT and send back for display
Can one servlet doPost() method handle all of this?