This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Where does servletContext object get passed onto Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Where does servletContext object get passed onto " Watch "Where does servletContext object get passed onto " New topic
Author

Where does servletContext object get passed onto

Adam Zedan
Ranch Hand

Joined: Jun 10, 2011
Posts: 124

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..


Don’t look where you fall, but where you slipped
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
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

 
GeeCON Prague 2014
 
subject: Where does servletContext object get passed onto