File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet Config and Servlet Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic

Servlet Config and Servlet Context

Vigneswaran Marimuthu

Joined: Aug 30, 2011
Posts: 24

hello all,

I need to know what will be present inside servlet config and servlet context ? I need a bit brief explanation. Any help will be appreciated. Thanks in advance !!!


Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

I am not sure of what you are asking.
I guess this can help:

A ServletConfig is "A servlet configuration object used by a servlet container to pass information to a servlet during initialization." ServelConfig can be used to get servlet specific initialization parameters configured in Deployment Descriptor.

A ServletContext: "Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. There is one context per "web application" per Java Virtual Machine."
All servlets have access to one servlet context which also can have init parameters. Also you can set attributes which can be an Object, in a servlet context, but not in a servlet config.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63837

Please check the JavaDoc for questions such as these.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Servlet Config and Servlet Context
It's not a secret anymore!