This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Servlets and the fly likes Difference Betn. ServletContext and ServletConfig!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference Betn. ServletContext and ServletConfig!!" Watch "Difference Betn. ServletContext and ServletConfig!!" New topic

Difference Betn. ServletContext and ServletConfig!!

Ravi Kumar Ravuru
Ranch Hand

Joined: Apr 18, 2002
Posts: 176
Hello Folks,
I would like to know the difference between the Servlet Context and Servlet Config.
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
ServletContext is the over all web application. These include the the parameters you list in the web.xml in the context-param element. (outside any servlet elements you specify) There is a single copy for any and all servlets and jsps running in the web application. Additionally, any Attribute you add to the ServletContext is available to them all and there is one and only one.
ServletConfig is the configuration for a single Servlet or JSP. These include the init-param you list within the servlet element of the web.xml. ServletConfig doesn't have the ability to set or get Attributes.

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
jQuery in Action, 3rd edition
subject: Difference Betn. ServletContext and ServletConfig!!
jQuery in Action, 3rd edition