简体   繁体   中英

Glassfish 3.1.1 Client session control

I'm having a little problem with Glassfish when trying to have some control over the httpsession created everytime a client access a web application i'm running. Thing is I want some temporary files to be created on the server side that will only last while the client is connected and be deleted from disk when client disconnects.

Thanks!

You can create a class which implements HttpSessionListner interface and, implement sessionCreated(HttpSessionEvent se) and sessionDestroyed(HttpSessionEvent se) methods. Those methods will be called, or simply your implemented class will be notified when there is a session created or destroyed in the application. You can use these two methods to do your work. And, you don't need to worry about client disconnected or close the browser, contained will do it for you.

You can get the session from HttpSessionEvent 's getSession() method. Then create or delete files for that session/user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM