Link to home
Start Free TrialLog in
Avatar of trobison
trobison

asked on

Accessing HttpSession object from jspDestroy()

Is it possible to access the session object in the jspDestroy() method from a JSP page?

I am trying to catch the session timeout to store current preferences in the database.

ASKER CERTIFIED SOLUTION
Avatar of harshita
harshita

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of trobison
trobison

ASKER

Yes harshita, you are correct. That is the alternative I have used, and it works pretty well for my solution.

However, I have other developers in my group that would like to access the session object in the init and destroy methods.

I think you can only get to the ServletContext level but you need the request to get the HttpSession object. I can get this far, but this only allows access to attributes bound to the ServletContext. Still cannot figure out how to get the session object from here?

      ServletConfig cfg = getServletConfig();
      ServletContext ctx = cfg.getServletContext();

Any ideas?
Thanks for your input....

Terry