webtier@glassfish.java.net

Re: Getting servlet class from a HttpSession

From: <webtier_at_javadesktop.org>
Date: Mon, 27 Jul 2009 04:08:43 PDT

Hi,

When you servlet creates the image then set an attribut in this session indicating that it was created by ...

session.setAttribute("createdByaServlet",true);

and then you can just do this :


public void sessionDestroyed(HttpSessionEvent se) {
if(session.getAttribute("createdByaServlet")){
    HttpSession s = se.getSession();
    ServletContext sc = s.getServletContext();
    File f = new File(sc.getRealPath("\\") + s.getId());
    f.delete();
}
}
[Message sent by forum member 'b_faissal' (b_faissal)]

http://forums.java.net/jive/thread.jspa?messageID=357657