Uploaded by javaprogrammingcbts 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
-
3 likes, 1 dislikes
6:28
Creating Stateless Session Beans (SLSB) with IRAD / WebSphereby javaprogrammingcbts2,832 views
29:28
Java Web Programming with Eclipse: Tomcatby csusbdt31,668 views
2:56
What is a Servletby binachemoux4,859 views
46:10
Session Tracking in Servlet Programmingby ignousocis10,004 views
9:08
Java Servletsby superboysales46,924 views
2:20
Using JDBC Connection Poolsby onsiteseminar4,245 views
9:14
Servlet Listener.flvby siva2cu510 views
9:58
servlet in a day HQ part1by EasyElearn3,369 views
59:53
Lecture -30 Client-Server Programming In Javaby nptelhrd55,922 views
7:33
JSP (Java Server pages) video tutorialby sharman210162,017 views
7:04
PortletModes: doEdit doView doHelp doPrint doConfigure: 168by tutorials168portlets2,204 views
6:23
Developing JSR168 Portlet Applications w IRAD for WebSphereby tutorials168portlets1,551 views
8:26
Action Processing Portlet: IRAD & RSA & WebSphere Portal WPSby tutorials168portlets818 views
5:49
Servlets Video Tutorialby sharman210153,183 views
0:55
Faster console with WebLogic Server 10.3by aseembajaj4,470 views
0:43
J2ee tutorialsby chandranac37,998 views
3:04
WebLogic Portal 10.0 Playgroundby meldaweling5,804 views
6:33
Introduction to J2EE | JEE TUTORIAL PART 1 - J2EE CLIENT AND SERVERby java9s29,467 views
7:33
JSP (Java Server pages) video tutorialby daniellestevensonus33,072 views
7:56
Using the PreferencesValidator in a JSR168 Portlet: Tutorialby tutorials168portlets1,086 views
- Loading more suggestions...
Link to this comment:
All Comments (0)