> > Why? My situation is that I have an n-tree data structure and I wish
> > to display the entire subtree for a given node. The task is an e-mail
> > address book in my company. I have organizational units in an n-tree
> > and e-mail users as leafes of organizational units. I don't think this
> > is too strange an idea. My original design was:
> >
> > - make one JSP do display leafes of the node (eUserDisp.jsp)
> > - add an option to display just the portion of the HTML code (so it can be 
>included)
> > - make one JSP to display subnodes of a node (OUDisp.jsp)
> > - add <jsp:include page="eUserDisp.jsp?partial=true&id=..."/>
> > - add an option to display just partial HTML (just the relevant portion inside 
><table>...</table>)
> > - add an option to, instead of displaying the list of nodes, include 
>"OUDisp.jsp?partial=true" for each node
> >
> > So, is this sane or not? I realize that making one JDBC connecion per
> > request can pile up connections, but now I know I can share them :-)
> > (I'm definitely insane :-))
> >
> 
> You could do your recursion *inside* a single page (or servlet) by
> repeatedly calling a method to write the sub-nodes of the tree to the
> response.  I've written JSP custom tags to do precisely this kind of
> thing, and it works quite reasonably.

In the end I guess I will, but I was so determined to get this recursion to work, I 
just wouldn't back down. I've got bumps on my forehead, but I've cleared some things 
in my head :-)

How does the idea of an internal method doing the recursion tie in with Struts 
concepts? Are you trying to tell me that switching my application design over to 
Struts and similar tools will favour that approach?

> > > > Or maybe I should employ connection pooling? Basically, every servlet
> > > > in recursion needs a connection, be it a new one or an existing one
> > > > from the pool...

One question on JDBC connection.

I realize I can use a global Connection object, initialized in jspInit() and destroyed 
in jspDestroy(). That way there would be just one JDBC connection per JPS/Servlet, no 
matter how many requests fly in, which is an improvement, not over my recursion 
approach (with n*m connections), but also over standard placing the Connection inside 
service() (with n connections for n requests).

This would mean that as long as the JSP is loaded it will keep a connection open. Is 
this a good approach? What happens if I shutdown the database? I don't think that the 
Connection will re-connect.

Nix.


Reply via email to