Thanks a lot ( excelent information )
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Kevin Duffey
Sent: Thursday, June 14, 2001 3:31 PM
To: [EMAIL PROTECTED]
Subject: Re: How to get rid of objects ( beans) when the user abandons
the sit e
There are a few things you can do. First, and not always recommended, is use
the onUnload="" in the <body> tag of a JSP page. When the user leaves the
page (closed browser, goes to another site, etc) you can call a javascript
routine that can then call the server with a specific request. I am not
sure, to be honest, if this works. I haven't tried it yet. The only thing I
can think of why it wouldn't work is if the window closes before the
unOnload handler is fired and carried out. Is it a matter of speed (does the
browser exit code wait for any unOnload routines to finish up..or just
arbitrarily close and not care what might still be running in the
client-side javascript context)..no idea.
The other thing to do..is set the session time-out to a really short period
of time. Then, use a META tag to set a timer on the page to monitor
inactivity. Set it about 2 minutes shy of what the server-side timeout is,
just incase their is network traffic and what not and the page gets back to
the browser slowly thus the timer on the page may not run out until after
the session-timeout on the server for that session. However, because this
isn't exactly in sync (browser to server), I don't recommend this much. You
can also specify in a message or something that the user has x minutes to
make a choice. If the choice is made after that period, they will be
presented with a page that lets them know their session expired.
Lastly, the approach I like best, but also requires a bit of download time,
is to use an applet on every page. The first time a user comes to the site,
the download of the page may take 20 second or longer though. You can
circumvent this by having just hte JSP pages involved in the transaction(s)
use applets. At any rate, by using an applet and javascript, you can
actually communicate with the server without ever changing the browser page.
JavaOne did this last year on their site. You checked off a checkbox, and
behind the scenes the applet updated something on the server, and the page
updated without a request going to the server. IT was very slick. Even
better, if every page uses an applet, you can monitor EXACTLY where each and
every person is on your site, without having to log it and pull a query on
the database to figure it out. You can also send pop-up messages and many
other things to any one on your site. For example, you can broadcast a
message from your server out to every client connected, which pops up a
message telling them the server will go down soon. Its very kewl stuff..but
it does involve a bit more code to get it working. I saw it done using
standard sockets programming..haven't yet done it myself. Basically, the
applet makes a socket connection to the server, and two-way communication
can occur. The only problem I see with this is a socket to the server is
left open, so that you can communicate with the applet. I don't imagine its
something you would want to do on a high-bandwidth e-commerce site. But, a
b-2-b site with not tons of people connected at the same moment might work
well. My point of the applet..is that you can send a message from an applet
to the server when the browser closes or user leaves the site. The applet
has some exit method capability that can then send off that last
communication telling the server to free up the memory, invalidate the
session, etc.
Good luck.
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Lenin Lopez
> Sent: Wednesday, June 13, 2001 4:07 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to get rid of objects ( beans) when the user abandons
> the sit e
>
>
> Thanks guys,
> let me see if I understand correctly,
> That means if I create objects in a servlet and put them in a
> session using
> the session.setAttribute, and if I use those objects in a jsp file. what
> you are saying is that I should not worry about unbinding the objects from
> the session???
> In other words I do not need to use the session.invallidate() to
> unbind the
> objects??
> Let me give you a scenario of my problem
>
> let say my JSP uses a worker bean (whose reference is store in a session )
> to display a list of available accounts from my DB, now that same
> page give
> the user the option to delete one of the available accounts from
> the list, (
> at this moment I still have a reference to my worker bean in a session )
> The user can continue with the deletion of one of the accounts on the list
> or the user can JUST LEAVE the site, if the user decides to do
> so, at this
> point, WHAT happens to my worker bean ( in the session )
> remember I did not invalidated it because I was going to use it
> in a future
> JSP ( assuming that the user was goint to continue with the process of
> deletion)
> Since the user as I said JUST LEAVES the site. How do I reclaim
> the memory
> in use by the session.
> Do I just wait until it expires???
> What if I have more than one object in the same situation??
> Thanks a lot for your input
>
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Chandra Patni
> Sent: Wednesday, June 13, 2001 1:12 PM
> To: [EMAIL PROTECTED]
> Subject: Re: How to get rid of objects ( beans) when the user abandons
> the sit e
>
>
> You can't get rid of objects as such because that's what GC is doing for
> you. All the object u are creating in your JSP will follow the
> same GC rule
> as other object created in any method. For beans you can specify the scope
> mechanism to control how long you want to keep the reference handle.
> I will NEVER suggest you finalize() method to do some 'smart things'. By
> overriding finalize(), you are effectively increasing the life of
> the object
> as GC now has to deal with this object at least twice.
> Regards,
> Chandra Patni
> Oracle Corp
>
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Lenin Lopez
> Sent: Wednesday, June 13, 2001 12:51 PM
> To: [EMAIL PROTECTED]
> Subject: How to get rid of objects ( beans) when the user abandons the
> sit e
>
>
> HI all,
> My question is how to get rid of object ( to avoid memory leaks) when the
> user 'just' abandons the site
> is there any way I can detect when the user leaves the page so I
> can triger
> some kind of event to get rid of my objects?
>
> Please
> Help
> Thank you all
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set
> JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets