"PATIBANDA, SRIKANTH" wrote:
>
> Scenario 1:(the request is trying to retrieve 5 rows out of some 500,000
> rows in the database.)
>
> lets say a user sends dopost request to servlet.. a thread is created..
> and user is waiting for a response.... Meanwhile user clicked the stop
> button
> on the browser...(I mention here its the browser button) it means from
> the user side the request has been cancelled..
>
> But if you check the JavaWebServer,  the thread is still hanging out
> there...
>
> (you can know whether this thread is still going on or not  at
> admin applet-->manage-->monitor-->resourceusage-->start view
> you can see under handler threads total---> avaialble...)
>
> my question comes here.. when does this thread die... or it will be there
> till it completes
> the request...

As far as you, the servlet writer is concerned, the thread runs until it comes
to the end of the method called by the servlet engine, usually doPost. Of
course, since the thread is created in the servlet engine, it actually continues
to run after the servlet completes, until it comes to the end of the method
start() in the servlet engine.

When the caller presses the stop button (or makes another HTTP request before
receiving the servlet's response), the thread runs until the servlet tries to
write to the output stream, at which point an IOException is thrown. If your
servlet catches the IOException, then your servlet could gracefully complete. If
your servlet does not catch it, or catches it and rethrows it, the servlet
server probably catches it and should terminate the thread gracefully.

> or
> is there any other way to kill this thread...

As has been discussed many times in this newsgroup, there is no good way to know
the user has interrupted the output stream, other than to catch the IOException
when your servlet writes to the output stream. Thus there is no easy way to end
the thread until the servlet is ready to respond back to the caller.

> Reason for this to be killed or stopped is: it slowing the javawebserver
> drastically. I can not make another request
> till this thread dies or stops.

Given a well behaved servlet server, and a correctly written servlet, you should
be able to make as many requests as you want. Remember where this started:
servlets are multithreaded. By definition, this means that you CAN make more
requests at any time because the servlet engine will start a new thread to
service the request.

What I think you meant is that subsequent requests are not serviced until the
first request completes. My first guess is that you synchronized a section of
code and created a bottle neck. There are other ways to make a servlet class
thread safe without synchronizing.

Kevin Mukhar

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to