File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes generating XML using servlets/jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "generating XML using servlets/jsp" Watch "generating XML using servlets/jsp" New topic
Author

generating XML using servlets/jsp

Ella Rath
Greenhorn

Joined: Apr 19, 2004
Posts: 17
Hi,
using HTML/javascript, a form has been created. now the user makes
selections using the form. i want to create a XML file that encapsulates
the user selections ie this XML file should contain the selections made
by the user. this XML file should also automatically change whenever the
user makes new selections on the HTML form.
a part of the HTML form is given below:
<form name="theForm">
<select name="sel" onchange="loadFile();">
<option> Choose the map u prefer
<option value="C:\My Documents\usa.jpg" height=50 width=20>US
<option value="C:\My Documents\uk.jpg" height=50 width=20>UK
<option value="C:\My Documents\spain.jpg" height=50 width=20>Spain
<option value="C:\My Documents\greece.jpg" height=50 width=20>Greece
</select>
</form>
now as soon as the user selects say,"US" from the options,
immediately the XML file should contain this selection. this XML file is
then sent to the server where a server side program extracts data from
the XML and does necessary processing.
my part is developing this dynamic XML. i have gone through some
tutorials but was unsuccesful. i want to know exactly how to use
JSP/Servlet to create the dynamic XML.
i just have no idea of how to start. if anybody can help me out by
starting the code development, i will continue it and develop the code.
this code is to have been developed by another person who has left
the project midway and now i am burdened with developing this code. i
have no time to read tutorials. so i request u to give me a pseudo-code
in JSP/servlet to generate this dynamic XML and i will proceed.
thanks in advance and eagerly looking forward to ur reply.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
what is the format of your XML File. I mean what tags are you using to capture this selection?
Ella Rath
Greenhorn

Joined: Apr 19, 2004
Posts: 17
Hi,
this is how i plan to write my XM file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<userselection>
<fig id="1">C:\My Documents\usa.jpg</fig>
<fig id="2">C:\My Documents\uk.jpg</fig>
<fig id="3">C:\My Documents\spain.jpg</fig>
<fig id="4">C:\My Documents\greece.jpg</fig>
</userselection>
from the above XML file, using JSP/Servlet, i need to generate a dynamic XML file that captures only the selections made by the user.
is the above procedure right?
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Use DOM(Document Object Model) or JDOM for this purpose. When the user selects something call a method which will write XML using DOM or JDOM.
Ella Rath
Greenhorn

Joined: Apr 19, 2004
Posts: 17
Hi Ali,
if u don't mind, can u please give me a sample code on how to call methods that write XML using DOM?
thanks in advance
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Checkout the code/examples given by Elliote Rusty Harold in this excellent book.
HTH,
- Manish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: generating XML using servlets/jsp