This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
When the valueUnbound method is called for the object on timeout, I first want to give a popup to the user asking if he wants to save a particular data.
1. Im not sure how to send the control back to the UI and to give user a popup from java? Need help on this. Im out of any clues.. 2. if he chooses to save the information, will the timeout wait till the processing is done? The processing will involve use of httpsession and backend update call too. So I was thinking may be it should be an "inactivity" due to which actually the timeout gets kicked off. Any comments?
Alongwith being a good coder, try to be a good professional as well!
HTTP is a stateless protocol. Servlets and JSPs can only respond to an HTTP request. Immediately after doing so the connection between the user's browser and the server is closed.
This means that events on the server have no way triggering anything on the client's machine. When your unbounded event fires, the server has no way of even knowing if the user's browser is even open, let alone still looking at your site.
This is not a good way of doing it.. But if your functionality demands it, you can...
[ April 18, 2007: Message edited by: Sunil Vasudevan ]
Sunil , will this really work ?
#3 : The session object is in the server.Timeout specify the maximum interval on inactivity after which the session can be invalidated and session is not thread safe , other requests can be working on the same session.
#3 : The session object is in the server. Timeout specify the maximum interval on inactivity after which the session can be invalidated and session is not thread safe , other requests can be working on the same session.
2. You invoke the timer with onload().
3. The session object is in server and can be accessed by other requests from the "same" client. And that would happen only if you open a new browser from the existing browser window using a CRTL+N. In this case the session ID is shared by both request. But other than that, if I start a new browser window, the same session object will not be shared. So technically what you are saying is possible, but that would happen only if the user tries to open a new browser from within an existing browser with an active session.
And well, I did mention it is a dirty solution. Don't expect the client and the server will be completely in synch.
On further thoughts, we can look at using AJAX. That should provide a cleaner solution.