This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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 REST with Spring (video course) this week in the Spring 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
I agree. Here's the link:
subject: Difference Betn. ServletContext and ServletConfig!!
It's not a secret anymore!