• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HttpSessionListener

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can someone help me in understanding the usage of HttpSessionListener Interface.

Thanks in Advance
Chandrasekhar S.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
package servlets;
import javax.servlet.*;
import javax.servlet.http.*;

public class SessionServlet extends HttpServlet implements HttpSessionListener
{

public void doGet(HttpServletRequest request,HttpServletResponse response)
{
try{
HttpSession session = request.getSession();
}
catch(Exception e){
System.out.println("Exception: " + e);
}
}

public void sessionCreated(HttpSessionEvent se)
{
System.out.println("Session Created ");
}

public void sessionDestroyed(HttpSessionEvent se)
{
System.out.println("Session Destroyed ");

}


}

If u see above SessionServlet has implemented HttpSessionListener. So when a session is created , method sessionCreated() is called. Similarly sessionDestroyed is called when session is destroyed by the container.

--
Atul
[ September 16, 2004: Message edited by: Atul Prabhu ]
 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Useful for clearing up database connections. HttpSessionListner and others (Context) are clearly explained in the following book:

SCWCD Exam Study Kit, Java Web Component Developer Certifcation
Deshmukh and Malavia

HTH
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic