IntelliJ Java IDE
The moose likes JSP and the fly likes Detecting page unloads ... Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Detecting page unloads ..." Watch "Detecting page unloads ..." New topic
Author

Detecting page unloads ...

Vikas Nair
Greenhorn

Joined: Jan 26, 2003
Posts: 3
Hi,
I am using an attribute in APPLICATION scope for concurrency checking. The problem is, the attribute has to be reset if (and only if) the user navigates out of the page without submitting the data (say ,by clicking the BACK button in the browser) ... So ,how do i detect that?
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
That would likely require the use of javascript and the onunload property of the body tag. Do your validation in a script, then set the page URL to be a page that does what you need it to do. The problem is that there's no guarantee that the JavaScript will run as you expect it to on the client's browser...
It might be best to reconsider your plan and look for alternate ways of knowing when to commit/rollback.


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
 
 
subject: Detecting page unloads ...
 
Threads others viewed
Session Id coming in URL for first time
error-page from JSP displaying inline instead of _self
autoFlush
<error-page> tag mechanism
Use of a page-scoped attribute
developer file tools