File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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
My XML File is as

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

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
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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.
I agree. Here's the link:
subject: Creating Dynamic JSP with XML
It's not a secret anymore!