Hi,
Really thanks for taking interest.
What my intension is that I want to develop a servlet based application
which will update the browser view as and when the system get some input
data comes to the server(may be coming to the server thru real time input).
For that, I'm using JMS and in the serverlet , I'm not clsoing the socket
i.e. servelet is waiting for the message. When some JMS message comes to the
servlet, the browser view is updated thru server push mechanism.
But the problem is that when a browser stop button being pressed leaves the
listener object still alive and that is of major concern.
This is the senario. I have also doing experiment with IOException raised by
the servletoutputstream.flush(). But still wanting more effective solution.
Thanks and Regards,
Sudarson
> ----------
> From: Tarun Ramakrishna Elankath[SMTP:[EMAIL PROTECTED]]
> Reply To: A mailing list for discussion about Sun Microsystem's Java
> Servlet API Technology.
> Sent: Saturday, April 28, 2001 8:43 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to detect browser stop -- it is possible!
>
> Hmm... (brain ticking)
> When you press the stop button on a browser, chances are that the
> browser has already send a request to a server and is waiting for a
> response. Ofcourse you could also have pressed the stop button when the
> browser is still issuing a request, but the time required for issuing a
> request is much greater than the time required for waiting for the
> response.
> (unless you have some huge POST data) .
> So the maximum that you could hope for is that the servlet throws an
> IOException when writing to the output stream. And then hope that the
> exception was thrown because the client clicked the stop button. This is
> loony logic because this IOException could be thrown for other reasons as
> well, such as the connection getting lost or timed out.
> I really dont believe that you could detect the stop button being
> clicked. There is no event handler in JavaScript that detects the stop
> button being clicked. (for very good reasons : - which is the script that
> should detect it ? the one that got unloaded or the one that is loading ?)
> You could get around this with some convoluted Javascript hacks that I
> do not recommend. One such tactic is
> that you could open a window with no stop buttons at all (and disable the
> hot keys) so that the only way the user can stop the page from loading is
> to
> close the window.
> Another would be to have a hidden frameset in each page (width &
> height
> =0) which has a script that monitors the activity of the links in the
> visible frameset, and checks that the link that was clicked on was loaded.
> This solution is more in the realm of DHTML than servlets and doesnt serve
> much purpose apart from making simple things complicated.
> About the cleaning up work, it depends on what volume of data you
> happen
> to have associated for each user session. You can either set timeout
> intervals for sessions or if you are reasonably sure that the client has
> terminated his/her session, you could manually get rid of the data
> yourself.
> You cannot "destroy" objects that are created within the servlets. At
> maximum, you can set their references to null and hope that the garbage
> collector collects them. If you are planning to destroy instance objects,
> then thats dangerous, because an instance of a servlet could be assigned
> multiple requests in different threads (unless you are using the
> SingleThreadedModel)
> I am actually quite confused as to what are you trying to do. Could
> you
> give a brief explanation of what are you trying to achieve ? Maybe we can
> accomplish it another way.
>
> ----- Original Message -----
> From: "Sudarson_Pratihar" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, April 28, 2001 3:42 PM
> Subject: Re: How to detect browser stop -- it is possible!
>
>
> > Thanks for the reply. But what you have talked about the Browser closing
> ,
> > I'm talking about the stop button(or interrupt) button of browser.
> > Is that applicable for that also?
> >
> > And if so, how can I destroy the objects that are created within the
> > particular servlet.
> >
> > Pls highlight on the clean up work.
> >
> > Regards,
> > Sudarson
> >
> >
> > > ----------
> > > From: Tarun Ramakrishna Elankath[SMTP:[EMAIL PROTECTED]]
> > > Reply To: A mailing list for discussion about Sun Microsystem's
> Java
> > > Servlet API Technology.
> > > Sent: Friday, April 27, 2001 8:36 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: How to detect browser stop -- it is possible!
> > >
> > > Well IT IS actually possible for the browser to inform the server that
> it
> > > has been closed.! You would have to do the scripting via JavaScript
> > > though.
> > > You could set a onunload() event handler for the window. This onunload
> > > event
> > > handler could then call a server-side script with the parameter
> > > close=true.
> > > The server-side script could then use this information to perform
> > > some-clean
> > > up operations. However the sever-side script SHOULD NOT write to the
> > > client,
> > > because by that time IE/NS would have closed the window down.
> > >
> > > A rough outline of how this works is like follows :
> > >
> > > <script language="javascript">
> > > window.onunload = function() {
> > > location.href="detect_close.jsp?close=true";
> > > }
> > > </script>
> > >
> > > You could do whatever you want in the JSP. Note that the JSP WILL KNOW
> > > which
> > > client has shut the window, because the browser would send the
> > > session/cookie data in the request just before the window shuts down.
> > >
> > > ----- Original Message -----
> > > From: "Kevin Mukhar" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Friday, April 27, 2001 7:56 PM
> > > Subject: Re: How to detect browser stop
> > >
> > >
> > > > Sudarson_Pratihar wrote:
> > > > >
> > > > > Is there any way to detect browser stop?
> > > >
> > > > No. It's been a while since we had this discussion here, but the
> answer
> > > > is still the same: the browser does not notify any server when the
> > > > browser is stopped or exited. You might want to check the archives
> to
> > > > review past discussions on this topic.
> > > >
> > > > > So that if a user clicks the
> > > > > browser stop, the servlet at the server side can be destroyed.
> > > >
> > > > You don't want to do this anyway. The servlet is a server resource
> and
> > > > should generally be available as long as the server is running. The
> best
> > > > way to deal with this situation is just to catch the IOException
> that
> is
> > > > thrown when the servlet tries to send the response to the client;
> since
> > > > the client no longer wants the response, there's really nothing else
> to
> > > > be done.
> > > >
> > > >
> > >
> __________________________________________________________________________
> > > _
> > > > 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
> > > >
> > >
> > >
> __________________________________________________________________________
> > > _
> > > 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
> > >
> >
> >
> __________________________________________________________________________
> _
> > 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
> >
>
> __________________________________________________________________________
> _
> 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
>
___________________________________________________________________________
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