aspose file tools*
The moose likes Servlets and the fly likes servlet context vs servlet config Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet context vs servlet config" Watch "servlet context vs servlet config" New topic
Author

servlet context vs servlet config

harish goyal
Ranch Hand

Joined: Aug 28, 2005
Posts: 51
can anyone help me what is differnce between
servlet context and servlet config?
suppose we have many servlet in our web application
than we have servlet config for every servlet
and there will be one servlet context;
please help me to understand this concept in better way
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
I believe someone asked this question just half a dozen posts below this one. Why don't you go and read the answers they received?

http://www.coderanch.com/t/361041/Servlets/java/servletContext-Vs-servletConfig

Or alternatively, look it up in the API
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/servletapi/javax/servlet/ServletConfig.html
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/servletapi/javax/servlet/ServletContext.html
shekar march chandra
Greenhorn

Joined: Jul 07, 2005
Posts: 25
Hi,

First of all, you should know that each and every servlet has a servletconfig object and for the entire web application per jvm you have only one servletcontext object.

servletconfig----------one for servlet.

servletcontext-----------one for web application.

Basically these are used for initializing parameters.

suppose you want something to be accessed by everyone, at that time go for servletcontext.Bcoz, if u keep that in context everyone can get to it.

suppose you want something to be available only to that particular servlet, then opt for servletconfig object.

Thanks,
chandra
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: servlet context vs servlet config