There are two problems: 1. missing the import statement: import javax.servlet.ServletContext;
2. it should be sce.getServletContext, not evt.getServletContext Additional, you need to remove the "throw new UnsupportedOperationException("Not supported yet.");", otherwise you will have error at run time. On Thu, Oct 15, 2009 at 11:27 AM, diego rangel <ingsopor...@hotmail.com>wrote: > hello friend: > > look at this,this is the myowneventlistener file: > > package mypackage; > > import javax.servlet.ServletContextEvent; > import javax.servlet.ServletContextListener; > import javax.servlet.ServletRequestEvent; > import javax.servlet.ServletRequestListener; > import javax.servlet.http.HttpSessionEvent; > import javax.servlet.http.HttpSessionListener; > /** > * Web application lifecycle listener. > * @author diego rangel > */ > public class MyOwnEventListener implements ServletContextListener, > HttpSessionListener, ServletRequestListener { > ServletContext servletContext; > > public void contextInitialized(ServletContextEvent sce) { > throw new UnsupportedOperationException("Not supported yet."); > servletContext = evt.getServletContext(); > servletContext.log("contextInitialized() method is invoked"); > } > public void contextDestroyed(ServletContextEvent sce) { > throw new UnsupportedOperationException("Not supported yet."); > > servletContext.log("contextDestroyed() method is invoked"); > } > > public void sessionCreated(HttpSessionEvent se) { > throw new UnsupportedOperationException("Not supported yet."); > servletContext.log("sessionCreated() method is invoked"); > } > > public void sessionDestroyed(HttpSessionEvent se) { > throw new UnsupportedOperationException("Not supported yet."); > servletContext.log("sessionDestroyed() method is invoked"); > } > public void requestDestroyed(ServletRequestEvent sre) { > throw new UnsupportedOperationException("Not supported yet."); > > servletContext.log("requestInitialized() method is invoked"); > } > > public void requestInitialized(ServletRequestEvent sre) { > throw new UnsupportedOperationException("Not supported yet."); > servletContext.log("requestDestroyed() method is invoked"); > } > } > > > > i run tthe file and this is the error: > > Compiling 2 source files to C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\build\web\WEB-INF\classes > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\mypackage\MyOwnEventListener.java:18: > cannot find symbol > symbol : class ServletContext > location: class mypackage.MyOwnEventListener > ServletContext servletContext; > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\mypackage\MyOwnEventListener.java:22: > cannot find symbol > symbol : variable evt > location: class mypackage.MyOwnEventListener > servletContext = evt.getServletContext(); > 2 errors > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\nbproject\build-impl.xml:401: The > following error occurred while executing this line: > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\nbproject\build-impl.xml:224: Compile > failed; see the compiler error output for details. > BUILD FAILED (total time: 2 seconds) > > > > ---------------------------------------------------------------------- > > Date: Wed, 14 Oct 2009 09:13:51 -0700 > > Subject: [java ee programming] Re: lab 4005 > > From: hieulu...@gmail.com > > To: java-ee-j2ee-programming-with-passion@googlegroups.com > > > > > > > Could you provide the content of the file: C:\Documents and Settings > > \diego rangel\Mis documentos\NetBeansProjects\hello2\src\java > > \MyOwnEventListener.java? > > > > On Oct 13, 2:05 pm, diego rangel <ingsopor...@hotmail.com> wrote: > > > apreciated friends: > > > > > > i have the following error when i go the exercise that coresponds to > the cicle life handlers an i run the myowneventlistener.java:(it correponds > to the lab4005): > > > > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:23: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext = evt.getServletContext(); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:23: > cannot find symbol > > > symbol : variable evt > > > location: class MyOwnEventListener > > > servletContext = evt.getServletContext(); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:24: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("contextInitialized() method is invoked"); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:30: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("contextDestroyed() method is invoked"); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:36: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("sessionCreated() method is invoked"); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:43: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("sessionDestroyed() method is invoked"); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:50: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("requestDestroyed() method is invoked"); > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\src\java\MyOwnEventListener.java:56: > cannot find symbol > > > symbol : variable servletContext > > > location: class MyOwnEventListener > > > servletContext.log("requestInitialized() method is invoked"); > > > 8 errors > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\nbproject\build-impl.xml:401: The > following error occurred while executing this line: > > > C:\Documents and Settings\diego rangel\Mis > documentos\NetBeansProjects\hello2\nbproject\build-impl.xml:224: Compile > failed; see the compiler error output for details. > > > BUILD FAILED (total time: 5 seconds) > > > > > > In the editor file apears the following : > > > > > > servletContext.log("requestInitialized() method is invoked"); > > > > > > servletContext is simbol not find > > > > > > any help that do you give me > > > thanks > > > > > > _________________________________________________________________ > > > > > > > > ------------------------------ > -- -Hieu --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en -~----------~----~----~----~------~----~------~--~---