Include XML Element value in JSP

Hi,I want to include an XML Element values in JSP Page.How can i Do this? I'm using DOM Parser to fetch data from XML File.If its possible, how can i store values in variables?Please help me.Thanks.
[241 byte] By [JChefa] at [2007-11-27 5:07:12]
# 1
what do you mean by including XML values in a JSP? Scenario? Hints?
kdajania at 2007-7-12 10:26:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hi,

Actually i'm developing a project in J2EE Env. And I've created a

XML File that stores the important data in elements. I want to

fetch those valeus and store them in to the JSP variables. How can

I do this? Is it possible to include XML File in JSP?

Thanks.

JChefa at 2007-7-12 10:26:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

There are many ways to do this. In my opinion, the best thing to do would be to:

- Break down your xml structure into Java Objects. i.e.

<emp>

<name>

<first>jeebus</first>

<last>wally</last>

</name>

<address>

<line1>123 sesame st</line1>

<line2 />

<city>townsville</city>

<zip>22222</zip>

</address>

</emp>

This XML would correspond to:

public class Emp {

private Name name;

private Address address;

public emp() {}

// getters and setters

}

public class Name {

private String first;

private String last;

public Name() {}

// getters and setters

}

//...etc plus the address class

XMLBean will do this for you if your schema is huge, provided that you have an XSD. http://xmlbeans.apache.org/

Once all your parsing of the XML is done on the server side, you can store your java objects that represent the XML in the session, and later retrieving it in your JSP.

Hope that helps.

kdajania at 2007-7-12 10:26:13 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...