• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

listener in Tomcat 4.0

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am using Tomcat 4.0.As you know,listener and filter are the new features of Servlet Specification 2.3 and Tomcat 4.0 support
these new features.I added D:\jakarta-tomcat-4.0-b7\common\lib\servlet.jar to CLASSPATH in my system,but I still
can not compile the following program.It produced "cannot resolve symbol class ServletContextEvent,ServletContextListener,...... "
Please help me.
--------------------------
<!--MyContextListener.java-->
package com.listeners;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributesListener;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public final class MyContextListener
implements ServletContextListener {
private ServletContext context = null;
public MyContextListener() {}
//This method is invoked when the Web Application
//has been removed and is no longer able to accept
//requests
public void contextDestroyed(ServletContextEvent event)
{
//Output a simple message to the server's console
System.out.println("The Simple Web App. Has Been Removed");
this.context = null;
}

//This method is invoked when the Web Application
//is ready to service requests
public void contextInitialized(ServletContextEvent event)
{
this.context = event.getServletContext();
//Output a simple message to the server's console
System.out.println("The Simple Web App. Is Ready");
}
}
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You obviously have an older version of servlet.jar still in your classpath.
With Java 2, you should never use the CLASSPATH environment variable. Delete it from your autoexec.bat. Always use the -cp or -classpath command line option:
javac -classpath .;path/servlet.jar MyContextListener.java
Also check to make sure the servlet.jar file is not in your JDK\JRE\lib\ext directory - that will take precedence over anything you specify in the classpath.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
ruijin yang
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Phil Hanna:
I cleared the problem.
Thank you very much!
-----------------
ruijin yang
SCJP2
reply
    Bookmark Topic Watch Topic
  • New Topic