This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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

Win a copy of Building Microservices this week in the Design forum!
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.
Have you checked out Aspose?
subject: Servlet Context
It's not a secret anymore!