File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes diff betwn ServletContext and ServletConfig Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "diff betwn ServletContext and ServletConfig" Watch "diff betwn ServletContext and ServletConfig" New topic

diff betwn ServletContext and ServletConfig

Mahesh Pinnamaneni
Ranch Hand

Joined: Jul 02, 2004
Posts: 100
hello friends,
i have searched the servlets forum and did not got any results for my topic in the i am posting here. would any one of u plz give me difference between ServletConfig and ServletContext with relavant examples and also situations where we can use them both.
Manish Jaju

Joined: Jul 21, 2004
Posts: 24
The Basic difference between them, servletContext is used for intercommunication between servlet to servlet/jsp and servletConfig is used to get initial parameters at the time of initialising servlet.
Raja Chandar

Joined: Aug 05, 2004
Posts: 6
ServletContext from context-param
ServletConfig from servlet init-param

ServletConfig is specific to a servlet and has values as defined in the
web.xml file as initial configuration parameters.

Whereas ServletContext is the context/application container where servlet operates
and has all the global parameters and multiple servlets runs.
[ October 07, 2004: Message edited by: Raja Chandar ]
I agree. Here's the link:
subject: diff betwn ServletContext and ServletConfig
It's not a secret anymore!