• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

generating XML using servlets/jsp

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the format of your XML File. I mean what tags are you using to capture this selection?
 
Ella Rath
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 572
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checkout the code/examples given by Elliote Rusty Harold in this excellent book.
HTH,
- Manish
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic