Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where does servletContext object get passed onto

 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I know that when a servlet config is created it is passed onto the init method.. However i am a bit confused about servlet context. When a servletcontext is created where is that passed i dont think its the init method as the init accepts only a servlet config object.?? and what happens when both a servlet config and aservlet context are to be passed to a servlet ?? wasnt it suppose to have a method like init(Servletconfig,servletcontext) or something like that ?? I hope someone could help me out clarify this concept... Thanks..
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Zedan wrote: what happens when both a servlet config and aservlet context are to be passed to a servlet ?? wasnt it suppose to have a method like init(Servletconfig,servletcontext) or something like that ?? I hope someone could help me out clarify this concept... Thanks..


Adam,

You dont have to do that. you can get the ServletContext from servletconfig.getServletContext() method. Please refer to the java docs.

http://download.oracle.com/javaee/6/api/javax/servlet/ServletConfig.html

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic