Re: Servlet problems

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: "'Nikola Milutinovic'" <Nikola(dot)Milutinovic(at)ev(dot)co(dot)yu>, "'PostgreSQL JDBC'" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Servlet problems
Date: 2001-12-17 15:04:15
Message-ID: 039e01c1870c$184b4d30$8201a8c0@inspiron
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Nikola,

I suspect that you are correct, you would have to look at the compiled
code to see what is going on. It is possible that it is using the same
result set? Either way you would be better reading the categories in a
class. In my servlet code I read the categories into a static tree. The
assumptions are

1) the category tree doesn't change a lot.
2) it is very costly to recurse through the tree

Dave

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Nikola Milutinovic
Sent: Monday, December 17, 2001 9:32 AM
To: PostgreSQL JDBC
Subject: [JDBC] Servlet problems

Hi all.

I'm a bit confused here. I'm using Tomcat JSP/Servlet engine. I have a
database in PostgreSQL, which holds a table describing an n-tree
structure (hierarchy). I would like my JSP page to able to display (if
parameter "print" is present) a complete sub-tree of a given node. This
is a simple recursion. What I'm trying to do is make our coroporate
E-Mail address book, so I have organizational units and users.

Without recursion everything works fine, all the direct subnodes are
displayed. When I use recusrion to include all subnodes, I get strange
errors.

First, it was killing the response in the middile of a table, in the
middle of a row. Now it dies with "NullPointerException: next()". In
other words, in one of the "ResultSet.next()" methods, it runs into a
non existant ResultSet.

I have tried putting a "breakpoint" (throwing a ServletException) on all
lines of my JSP page. When there is a "breakpoint" I do not run into a
NullPointerException. When I remove it, I have exception.

My conclusion was that I get the error AFTER my JSP page starts emerging
from the recursion (if it was inside recursion, it would have been
stopped by the "breakpoint"). So, after a page calls itself once, the
"insider" does it's thing and then exits and releases control to it's
caller, the the exception occurs.

I must admit that JSP page closes it's JDBC objects, I thought it would
be OK, since the page creates them.

This is the flow of events:

OUDisplay.jsp [instance 1]:
----------------------------
DriverManager.getConnection()
Connection.createStatement()
Statement.executeQuery()
while( ResultSet.next() ) {
...
<jsp.include page="OUDisplay.jsp" />

OUDisplay.jsp [instance 2]:
----------------------------
DriverManager.getConnection()
Connection.createStatement()
Statement.executeQuery()
while( ResultSet.next() ) {
...
}
ResultSet.close()
Statement.close()
Connection.close()
--------------[instance 2]-

}
ResultSet.close()
Statement.close()
Connection.close()
--------------[instance 1]-

The problem occurs inside the outer "next() {...}", which leads me to
believe that Some objects in the "instance 1" get screwed up, but I
don't know how.

Any insight?

Nix.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nick Fankhauser 2001-12-17 15:17:29 Re: Servlet problems
Previous Message Antonio Fiol Bonnín 2001-12-17 14:54:30 Re: Servlet problems