This will never work!

The include statement will get a new connection to the database and execute
an entirely new
query, while the first query / result set is active. You will quickly run
out of connections.

Secondly, at the risk of parroting earlier responses, I would heartily
suggest that you move this
logic to a bean and/or a custom taglib. Your life will quickly become a
living hell if you try to
place too much java code in your JSP's. JSP's are great at formatting
output, they are a
terrible place for anything but the most straightforward Java code.

I think that you'd be better off thinking about how to build up the nested
data structure
you need, then feed this nested data structure to your JSP, which simply
needs to format
it as HTML.

Tom Drake

----- Original Message -----
From: "Nikola Milutinovic" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Monday, December 17, 2001 11:08 PM
Subject: Re: What's the word on a Servlet/JSP including itself in recursion?


| > How are you passing the resultSet back and forth between the JSP's?
|
| I'm not. This is the scatch of the code:
|
| JSP: OUDisplay.jsp
| --------------------
| DriverManager.getConnection()
| Connection.createStatement()
| Statement.executeQuery()
| while( ResultSet.next() ) {
|   ...
|   if( recurse ) {
|     <jsp:include page=<%= \"OUDisplay.jsp?partial=true&id=\" + id %>" />
|   }
|   ...
| }
| ResultSet.close()
| Statement.close()
| Connection.close()
| -------------------
|
| Now, I have tried putting a "breakpoint" in my JSP (throw
ServletException). Wherever I put it, the JSP page runs into it, but the
NullPointerException doesn't occur. I've tried putting it on the last line
of JSP, still no NullPointer.
|
| This lead me to believe that the error is occuring AFTER my JSP emerges
from a recursion. So, it goes into the loop, calls itself once (there was
only one level of sub-tree in that test example), the called JSP finishes
it's job, resturns to "upper itslef" and then inside that "while(
ResultSet.next() )" I get the error. Like the JSP page that was called in
the recursion closed not just it's own JDBC objects, but also it's parents.
|
| Any comment?
|
| Nix.
|


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to