Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP and XML

 
Dan Taylor
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a newbie to JSP and frankly I don't know how to do much with it. I recently completed a semester learning Java but we didn't cover servlets, beans, or JSP.

I need some simple instructions to perform a simple task in a JSP page.

I am being supplied an XML document and I need to generate an HTML report from the data contained in it.

My question is how do I get the data from the XML doc into my JSP page?

I have been trying to find a good resource but everything seems to point to custom tag libraries to JSTL and other things that I am completely unfamiliar with. This seems like it would be a simple process of pointing my JSP to the XML doc somehow and using the XML field tags as variables.

second, once I have figured out how to all that, how do I get it to pull the info multiple times to create a table of information.

I hope this is simple and I am not asking a lot of anyone. I have a week to figure this out, code it and test it. Below is a copy of the sample XML I was provided:



thanks
Dan
[ May 24, 2004: Message edited by: Bear Bibeault ]
 
Ali Gohar
Ranch Hand
Posts: 572
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See DOM(Document Object Model) or SAX(Simple API for XML Parsing) to parse the XML file. To transform the XML into HTML see XSLT. Without these APIs i don't think you can solve the required problem.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posting only a snippet of the XML would have been enough too, seeing as the data repeats itself [Bear: done]

As Ali suggests, look at XSLT to transform the data into HTML.
If you want to do that inside JSP, also look at the JSTL XML tags, which include XSLT support.
[ May 24, 2004: Message edited by: Bear Bibeault ]
 
Charles Hasegawa
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the task you have is certainly simple, if you have experience in the various Java XML APIs and JSPs. Given what you described as your level of Java understanding, I'd say you are looking at a fairly tough task overall.

The easiest thing I can see you for you to do, is get the JSTL tag libaries and look at the XML related tags.

Here is a good starting reference: www.manning-source.com/books/bayern/bayern_apxA.pdf
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic