You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gerd Trautner <38...@t-online.at> on 2001/03/02 16:59:55 UTC

Re[3]: memory and/or ms problem

hi all,

i found the reason for the growing memory consumption of my servlets.

preconditions:
i use servlets to get data out and in a mysql database and generate
html pages with PrintWriter.print(...) statements.
my servlets often use:
...
Statement Stmt = C.createStatement();
ResultSet RS = Stmt.executeQuery("SELECT ..,..,.. from ..");
while (RS.next())
{
   //do something with data
   out.println(....);
}
...

each request an instance of a servlet is created and the servlet
starts reading data out of the database and writes it in the
PrintWriter stream.
But what happens if the PrintWriter has no target (because the user
sends another request or more then one other requests)? I am not sure,
but it seems that the servlet tries to write to the PrintWriter stream
and has no success. the result is a growing amount of instances of a
servlet which try to write to a PrintWriter and have no success. and
it seems they keep try writing (and consuming memory) a long time ...

my solution is to check the error state of a Printwriter before
writing in it. so the code from above looks like this:
...
Statement Stmt = C.createStatement();
ResultSet RS = Stmt.executeQuery("SELECT ..,..,.. from ..");
while (RS.next())
{
   if (out.checkError()) break;
   //do something with data
   out.println(....);
}
...

for my application it seems to work, but i think there must be a better
way,
any ideas?

Gerd


Client Certificate Authentication

Posted by Cory Hubert <cl...@invertica.com>.
	Anyone know how to configure your web.xml to accept Client-Certificates.