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 Context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Context" Watch "Servlet Context" New topic

Servlet Context

syed askari

Joined: Aug 22, 2002
Posts: 6
What is ServletContext. Why we use it.
Todd Sanders
Ranch Hand

Joined: Jan 07, 2002
Posts: 33
You use ServletContext if you want your object visible to all the clients of the web application installed in a container. These objects remain there for the life of the application and can be shared with other servlets.
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
The ServletContext basically represents your web application. This is where your servlets "live." So, as Todd said, you can share data among your servlets by setting attributes on the ServletContext. ServletContext attributes are web application-wide. They are not specific to any one user (for that use HTTPSession attributes). They are not specific to any one request (for that use ServletRequest attributes).

James Carman, President<br />Carman Consulting, Inc.
I agree. Here's the link:
subject: Servlet Context
It's not a secret anymore!