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