• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

servlet cant see getServletContext() from inheritance

 
EM. Lashkar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there ,
While implementing MVC architecture ,
I made an abstract ParentController.java which is extended by ApplicationController.java. In the ApplicationController I am doing :
// get the application object
ServletContext app = getServletContext();

// select login.jsp as the template
RequestDispatcher disp;
disp = app.getRequestDispatcher("index.jsp");
and at compile time I am getting:
ApplicationController.java:46: cannot resolve symbol
symbol : method getServletContext ()
Any idea? Thanks in advance for your comments .
Here are the code of the 2 classes :
----------------------------------------------

----------------------------------------------
----------------------------------------------

[ December 15, 2003: Message edited by: Mike Curwen ]
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think all your subclasses will need to define

public void init(ServletConfig config) throws ServletException {
super.init(config);
}

?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic