Meaningless Drivel is fun!
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet context vs servlet config" Watch "servlet context vs servlet config" New topic

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

Joined: Jul 06, 2005
Posts: 1580
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?

Or alternatively, look it up in the API
shekar march chandra

Joined: Jul 07, 2005
Posts: 25

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.

I agree. Here's the link:
subject: servlet context vs servlet config
It's not a secret anymore!