File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Difference Betn. ServletContext and ServletConfig!!" Watch "Difference Betn. ServletContext and ServletConfig!!" New topic
Author

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.
Regards,
Ravi
Carl Trusiak
Sheriff

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
 
Don't get me started about those stupid light bulbs.
 
subject: Difference Betn. ServletContext and ServletConfig!!