Ok I checked a little further into it because I honestly couldn't remember
what it was supposed to do. A PrintWriter that is being used by a servlet to
send character data never throws any exceptions.  The checkError() method is
supposed to flush the remaining output and if there was a problem writing to
the OutputStream it will return true or if the client has stopped the
request.  The method is mostly used on long running servlets to find out if
it can terminate processing early.  Now that I think I understand the
question better. Cost/Benefit.  A set of instructions  that takes less than
1 second is probably not worth constantly checking and creating the
additional I/O overhead for flushing which will also make your servlet run
longer.  Greater than a second maybe, more than 10 second a little more
definite, if possible.  If it does terminate early, just return.


Example:

out = response.getWriter();
out.print("<table>");

for(i = 0; i < 500; i++) {
      out.print("<tr><td>");
        out.print("Working on transform: " + i);
        out.print("</td></tr>");
        if(out.checkError()) return;
        
        //calculate next fourier transform
                
}
out.print("</table>");


That would print out a table as it was working and when it checks it will
spit out that it was working on the that transform before it actually does
the calc.

Chris Berthold
IT Systems Analyst
Commercial Refrigerator Door Company
941 . 371 . 8110 x 205

-----Original Message-----
From: Chris Berthold [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 04, 2006 2:29 PM
To: 'Tomcat Users List'
Subject: RE: should I call Servlet.destroy() if
response.getWriter().checkError() is true?

I would have to think it would set the the http status to 500 and then
return.  Servlet.destroy() is called when the container decides that servlet
object should be unloaded.

Chris Berthold
IT Systems Analyst
Commercial Refrigerator Door Company
941 . 371 . 8110 x 205

-----Original Message-----
From: Nikita Tovstoles [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 04, 2006 2:01 PM
To: users@tomcat.apache.org
Subject: should I call Servlet.destroy() if
response.getWriter().checkError() is true?

I read somewhere that if response.getWriter().checkError() returns true 
"servlet should terminate". Do you think "terminate" means simply 
"return" or actually Servlet.destroy()?

thanks
-nikita


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to