8 messages in com.mysql.lists.javaRe: How to stop a servlet| From | Sent On | Attachments |
|---|---|---|
| Emanuel Dejanu | 25 Jan 2000 08:00 | |
| LEBLANC, CLAUDE | 25 Jan 2000 12:41 | |
| Mark Matthews | 25 Jan 2000 13:25 | |
| john gregg | 25 Jan 2000 15:43 | |
| LEBLANC, CLAUDE | 15 May 2000 11:17 | |
| Tim Endres | 15 May 2000 12:40 | |
| LEBLANC, CLAUDE | 16 May 2000 12:00 | |
| Christian Mack | 23 May 2000 23:01 |
| Subject: | Re: How to stop a servlet![]() |
|---|---|
| From: | Mark Matthews (mmat...@thematthews.org) |
| Date: | 01/25/2000 01:25:57 PM |
| List: | com.mysql.lists.java |
----- Original Message ----- From: "LEBLANC, CLAUDE" <clau...@bell.ca> To: <ja...@lists.mysql.com> Sent: Tuesday, January 25, 2000 2:42 PM Subject: How to stop a servlet
Hello,
I have a bunch of servlets that make requests to a mySQL database and it works very well.
I have a problem : how do we stop execution of servlets when the client clicks STOP or BACK buttons in the browser.
An IOException will be thrown when you try to write to the output stream that is hooked up to the browser.
Right now clicking STOP button causes the browser to stop the display but doesn`t stop the servlet execution. So if we click BACK and re-run another query (suppose the first result was very long), there will be two servlets instances running and the result page shows the two outputs interlaced. Cool but not desired.
It looks like you are using a class variable that doesn't have it's access synchronized. doGet() can be called from multiple threads (one for each browser calling the servlet, to be simplistic), and if you are using a single shared-instance variable wierd things can happen.
I would recommend using some sort of connection pooling mechanism in your servlet, as well as avoiding using any instance variables while processing doGet() unless you have synchronized access to them.
-Mark (author of MM.MySQL)




