In which conditions we have to use the ServletContext

Showing Answers 1 - 18 of 18 Answers

raghava

  • Oct 17th, 2005
 

When we want to deal with the web application we use servlet context

  Was this answer useful?  Yes

sang

  • Oct 22nd, 2005
 

Actually in servlet we wont use the MIMe type content when the User wants to view more attractive page we use the Servlet contexton that time we have to use Servlet context by santhakumar

  Was this answer useful?  Yes

Lavanya.G

  • Oct 28th, 2005
 

Data which is global.I.e any class can use that data

  Was this answer useful?  Yes

Bhupender Giri

  • Nov 9th, 2005
 

There are several situations when u need to Use ServletContext

One general one is that when ever u need to get

RequestDispatcher object.

  Was this answer useful?  Yes

BhupenderDonGiri

  • Nov 9th, 2005
 

To get RequestDispatcher object.

Not only this but there are several other conditions too to Use ServletContext

  Was this answer useful?  Yes

Raghavendra Sai

  • Nov 18th, 2005
 

One situation is when your application wants to communicate with other Application., i.e., for communication between applications

  Was this answer useful?  Yes

Ajit

  • Dec 29th, 2005
 

ServletContext contains the runtime environment information for all the servlets of the web application in question. In short, ServletContext's API 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.

  Was this answer useful?  Yes

sirisha

  • Mar 9th, 2006
 

The ServletContext object enables you to store information about your application and access environment information, such as the following:

  • Initialization parameters
  • MIME type
  • Version information
  • Path information

Servlets use the getServletContext method to obtain a reference to the ServletContext object.

  Was this answer useful?  Yes

milind tujare

  • Apr 6th, 2006
 

Data

  • Initialization parameters
  • MIME type
  • Version information
  • Path information

is shared between the servlets as : One servlet puts the data in a well known place,which acts as a container and other servlets access the data from that place.These well known container or objects are;

ServletRequest  -- accessible only for the life of the request

HTTPSession    -- accessible only while client is active

ServletContext  --accessible for the life of the web Application

All the three Objects provide a method as:

- setAttribute();

- getAttribute();

  Was this answer useful?  Yes

Gita

  • Jan 28th, 2012
 

http://tomcat.apache.org/tomcat-4.1-doc/servletapi/javax/servlet/ServletContext.html go through this link u will find setAttribute() method.

  Was this answer useful?  Yes

sujata waghmare

  • Jan 10th, 2014
 

we can use servletcontext it condition whole application only one object...dont change a servlet...only change a web.xml file...one object use to whole application that situation use a servletcontext...servletcontext object is not used particular servlet...servletcontext is used to whole application that situation...use.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions