Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet context vs servlet config  RSS feed

 
harish goyal
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1834
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!