Ryan,

How dynamic are your XML pages?  I am taking a different approach for
certain reasons:

1 - The XML documents are very "templateish"  There is some looping and
placing data in between tags, but little if-then type logic.

2 - We don't want to hard code the XML, allowing an end user to work on the
formating of the page

3 - Most of the good XML examples I've seen use the xml4j from IBM.  The bad
thing is that you essentially hard code the DTD in the java code.
(child.addElement, grandchild.addElement etc.) A change or addition or
deletetion from the DTD means modifing your java code and recompiling.  It's
like the old days when you had a ton of print statements to create HTML,
then you had to keep modifying the java code to get the HTML renering to
look good.

So what I think I'm going to do is call the JSP from java code (NOT through
a web browser, using a tool that lets you do this)  The majority of the JSP
pages looks like
<XMLTAG>bean.getName()</XMLTAG>
while thisthing.hasMoreElements
{
<MORETAGS>bean.getData()</MORETAGS>

}
etc.  Where it is the beans responsibility to get the data from the database
and do what it needs to with it.

It is like using JSP instead of creating our own scripting language.

Just a thought.  But let me know what you think and end up doing.

- Ed

-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Shriver, Ryan
Sent: Friday, April 28, 2000 11:22 AM
To: [EMAIL PROTECTED]
Subject: JSP/JavaBean/XML Architecture


Hello all,
We're developing a Java site for a customer and I wanted to get some
feedback on the architecture we're using. Specifically, how is anyone else
out there getting their XML data from a database into the JSP page?

>From the top down, our architecture is:

JSP
JavaBeans
Middle-layer Java classes
Database-layer Java classes
Database

All SQL queries that return ResultSets get parsed into an XML Document at
the Database-layer and returned up the chain to the JavaBean. Once the XML
is in the JavaBean, we've used three different approaches for rendering its
data on the JSP.

Originally we were parsing the XML into a Vector and passing this back to
the JSP, which would iterate through the Vector and display the results.
This worked OK, but there was overhead converting the XML to the Vector,
passing the entire Vector back to the JSP and then casting back to the
appropriate type.

Solution #2 was to parse the XML into a Vector but leave the Vector in the
Bean. We wrote an iterator method in the Bean that wrapped the Vector,
something like:
        public Object getNextAddress(){}
>From the JSP you would call JavaBean.getNextAddress() on the Vector to get
the next item in the Vector, cast it to the correct type and then use it in
the page.

Solution #3, the most current solution, is to pass the XML back to the
JavaBean and wrap the XML document with an iterator method in the Bean. Same
idea as above, but
        public Object getNextAddress(){}
gives me the next ElementNode in the XML Document, from which I can pick out
the pieces of data I need to display on the page using
ElementNode.getAttribute(). When getNextAddress() returns a null (ie there
are no more Elements in the XML), I quit my looping on the JSP page. It's
the simplest and most elegent way I've found thus far of getting the XML
data into a JSP page.

Is anyone else doing this? If so, how are you doing it? I think I'm on the
right path but it's always good to have some peer feedback. Thanks.

                                                                ryan

Ryan Shriver - Consultant
The Whitlock Group eBusiness Solutions
[EMAIL PROTECTED]

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to