Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Creating Servlet Engine Lifecycle Listeners: IRAD WebSphere

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,155
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 4, 2008

Creating Lifecycle Listeners

This free, multimedia tutorial shows you how to use IBM's Rational Application Developer (IRAD) 6.0 to create a lifecycle listener that will respond to the creation of an HttpSession, or the initializing of a web application. In other words, the component created implements the HttpSessionListener and the ServletContextListener interfaces. How's that for excitement?

If you found something helpful here, please do your part and help support the site. Link to us, buy some books, support our sponsors, tell your developer friends about us, and remember: Happy Java!

package com.examscam.web.listener;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

public class MyKewlListener implements ServletContextListener, HttpSessionListener {


public void contextInitialized(ServletContextEvent contextEvent) {
contextEvent.getServletContext().setAttribute("timestamp", new java.util.Date());
System.out.println("Context Initialized");

}


public void contextDestroyed(ServletContextEvent arg0) {
// TODO Auto-generated method stub
}


public void sessionCreated(HttpSessionEvent sessionEvent) {
String magicKey = ""+ System.currentTimeMillis() % 100;
sessionEvent.getSession().setAttribute("magicKey", magicKey);
System.out.println("Session Initialized");
}

/* (non-Java-doc)
* @see javax.servlet.http.HttpSessionListener#sessionDestroyed(HttpSessionEvent arg0)
*/
public void sessionDestroyed(HttpSessionEvent arg0) {
System.out.println("Session Destroyed");
}

}

View the original video here:

http://jpa.thebookonhibernate.com/j2ee/sunjavasamplecodetutorialsmockexams.js...

Check out my Hibernate tutorials:

http://www.thebookonhibernate.com

Check out my free SCJA mock certification exams:

http://www.scja.com/associate/index.jsp

  • likes, 1 dislikes

Link to this comment:

Share to:
see all

All Comments (0)

Sign In or Sign Up now to post a comment!
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more