java - Call an action when closing a JSP -
I'm new to the Java web world, please forgive me if I say something stupid.
I am working with struts 2 and I need to delete a file (which is located on the server) when a JSP stops.
Does any body know this?
Thanks in advance.
window.optimize
suggestions are good, but there is no guarantee that AJAX requests will ever kill the server. As far as I remember, only a few IE versions with certain configurations will send the AJAX request successfully. Firefox and others will not do this and then I do not talk about cases when JS is disabled in the user.
You do not want to trust it. Hook at the end of the session. You can do that with help or when it may be related to the (existing) attribute of the session.
Example
Apply Public Class Cleanup Sessions HttpSessionListener {@Override public void sessionDestroyed (HTTPP events event) {new file (some paths) .delete (); } // ...}
(registered in web.xml
as a and lt; listener & gt;
Or "logged-in user" in the case of an example (which is stored in the scope of the session):
The public uses the zero user HttpSessionBindingListener { @Override Public Zero ValueAnband (HttpSessionBindingEvent event) {new file (somePath) .delete (); } // ...}
Comments
Post a Comment