tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From johannes.fi...@fwd.at
Subject RE: [off topic] - passing a ResultSet from a servlet to a JSP
Date Tue, 29 Apr 2003 20:24:15 GMT
Hi Shapira,

I've had the same issue, so I'm tempted to jump into this discussion.

This technique is fairly ok, if the resultset is expected to be approx. 
1000 records.
If you have 10.000 records with size of 100 Bytes each, you have 1 MB 
sitting in request.setAttribute() and passed to the JSP. This 1 MB gets 
garbage collected some seconds later by the JVM.
I tried this technique with an even bigger resultset of 50.000 records, 
which is likely to slow down Tomcat and require lots of memory if users 
simultaneously surf around with this size of recordsets. I was able to 
capture more than 50 MB easily simple by reloading a page in MS IE 
repeatedly.

The only way I found around this so far is to allow navigation across the 
resultset, which shifts the problem to the server/database system to allow 
for fetching the records using LIMIT-clause in mySQL for example or to use 
cursors to navigate in the resultsets. This works fairly good, but only if 
users are satisfied having to browse inside the lists. 
Additionally, the database server has to work quite optimized for this 
LIMIT-statement, as it is re-calculated for each request. Does anybody 
have a better solution for this (cursors? EJBs??).

I haven't yet found a fine solution to this problem, maybe others have?

thx alot
Johannes




"Shapira, Yoav" <Yoav.Shapira@mpi.com> 
29.04.2003 20:18
Please respond to
"Tomcat Users List" <tomcat-user@jakarta.apache.org>


To
"Tomcat Users List" <tomcat-user@jakarta.apache.org>
cc

Subject
RE: [off topic] - passing a ResultSet from a servlet to a JSP







Howdy,

>4) Puts the ResultSet into the session
>5) Forwards to a JSP page
<snip>
>soon as the dB connection is closed. So how can it be working? And more
>importantly, what's a better way of accomplishing this?

Don't send ResultSets around.  Instead, have the servlets loop through
the result set and create whatever object you need to hold the result
set's contents.  Then close and discard the result set (and statement,
and connection to the db, etc, all in a finally {} block or whatever to
ensure they execute blah blah blah). 

Instead of passing the resultset, pass this object.  You have more
control over its implementation, whether it's serializable, etc.  As you
noticed, the ResultSet interface is subject to different implementations
in different JDBC drivers (even drivers from the same vendor for the
same DB on different platforms).  This makes the ResultSet object a bad
candidate for a session attribute, because variable platform-dependent
behavior tends to occur.

Yoav Shapira
Millennium ChemInformatics



This e-mail, including any attachments, is a confidential business 
communication, and may contain information that is confidential, 
proprietary and/or privileged.  This e-mail is intended only for the 
individual(s) to whom it is addressed, and may not be saved, copied, 
printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your 
computer system and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message