• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContextListener Error

 
Steve Jerome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting error message when I tried to compile following program saying cannot find symbol ServletContextListener,ServletContextEvent.

package com.example;
import javax.servlet.*;

public class ListenerClass implements ServletContextListener
{
public void contextInitialized(ServletContextEvent event)
{
ServletContext sc = event.getServletContext();
String s=sc.getInitParameter("book");
Book b=new Book(s);
sc.setAttribute("typebook",b);
}
public void contextDestroyed(ServletContextEvent event)
{

}
}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you put servlet-api.jar in your CLASSPATH ?
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you set your classpath pointing to the servlet-api.jar when you compile?
 
anand gun
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please confirm whether you were able to complie other servlet classes?
 
Steve Jerome
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.Actually I was using older version of tomcat.After installing newer version the file compiled without error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic