aspose file tools*
The moose likes JSP and the fly likes Creating Dynamic JSP with XML Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Creating Dynamic JSP with XML" Watch "Creating Dynamic JSP with XML" New topic
Author

Creating Dynamic JSP with XML

madhup narain
Ranch Hand

Joined: Dec 14, 2004
Posts: 148
Hi all:

My requirements are that i need to create dynamic pages from an XML file.
The XML file is a simple file that is not nested. However i have no idea how to access the values of the XML file in a JSP page.
Could someone direct me as to how i could access the XML values without too much of code
Eg.
My XML File is as

<FILE>
<A> a </A>
<B> b </B>
<C> c </C>
<D> d </D>
<E> e </E>
</FILE>

i would like to use the values a,b,c.. in my JSP page.
I came across XSLT but it seems to have browser support issues (IE6 and above, Opera 8).
I would like to have maximum browser support and little processing to access my XML file. Remember that the same XML contents may be used in the next jsp page.

Thanks ..


Money for nothing and Java for Free
SCJP, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
You have lots of choices - these are off the top of my head:
1. In a separate Java class, read the XML file into a Document object and provide for "bean"like access methods that will use either XPath or org.w3c.dom package methods to extract the values as needed.
2. Use in-process XSLT - see the javax.xml.transform package
3. Use the standard tag library - do a search for "JSTL XML" to get plenty of references.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating Dynamic JSP with XML