| Author |
ServletContextListener
|
Ravinder S Edhan
Ranch Hand
Joined: Dec 15, 2003
Posts: 57
|
|
Hi All, I'm try'n to write a listner class. ************************************************* package com.example; import javax.servlet.*; public class MyServletContextListener implements ServletContextListener { public void contextInitialized(ServletContextEvent event) { ServletContext ctx = event.getServletContext(); String refDog = ctx.getInitParameter("breed"); Dog d = new Dog(refDog); ctx.setAttribute("dog",d); } public void contextDestroyed(ServletContextEvent event) { //No implemantation required yet. } } *********************************** The above is an example from Head First Servlet and JSP. While compiling the file I'm getting following error Compiling command: javac -d web-inf/classes src/*.java Error: src/MyServletContextListener.java:5: cannot resolve symbol symbol : class ServletContextListener location: class com.example.MyServletContextListener public class MyServletContextListener implements ServletContextListener { ^ src/MyServletContextListener.java:6: cannot resolve symbol symbol : class ServletContextEvent location: class com.example.MyServletContextListener public void contextInitialized(ServletContextEvent event) { ^ src/MyServletContextListener.java:19: cannot resolve symbol symbol : class ServletContextEvent location: class com.example.MyServletContextListener public void contextDestroyed(ServletContextEvent event) { ^ 3 errors The carrot sign are coming under ServletContextListener, ServletContextEvent I don't know why. Thanks in advance Ravinder S Edhan [ January 11, 2005: Message edited by: Ravinder S Edhan ]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Do you have the servlet libs on your CLASSPATH? For recent versions ofTomcat, they're in TOMCAT_HOME/common/lib/servlet-api.jar Your container's mileage may vary. [ January 11, 2005: Message edited by: Ben Souther ]
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Ravinder S Edhan
Ranch Hand
Joined: Dec 15, 2003
Posts: 57
|
|
Hi Ben Thanks for the reply. After specifying the CLASSPATH for 'servlet-api.jar' the files compiled. Cheers Ravinder S Edhan
|
 |
 |
|
|
subject: ServletContextListener
|
|
|