dcsimg
What is servlet context
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   chenna_dulla
Posted On:   Monday, December 3, 2001 02:11 PM

Hi,

I know servlet context is used to interact with its environment.
What does it mean.

Re: What is servlet context

Posted By:   Alex_Chaffee  
Posted On:   Thursday, December 6, 2001 03:02 PM

Chenna, please search the FAQ before posting. There is lots of information on ServletContext -- just type "ServletContext" into the Search box and you'll see.

Re: What is servlet context

Posted By:   Bozidar_Dangubic  
Posted On:   Tuesday, December 4, 2001 09:01 AM

ServletContext defines a set of methods which servlet can use to communicate with the container to which it is deployed. Each servlet is deployed in a given servlet container which manages things such as dispatching requests to specific servlets and so on.


ServletContext has multiple purposes. It allows you to

  1. share data between servlets that share the same context. if one web application has several servlets, they can use ServletContext to share data
  2. allows servlets to read initialization parameters specified during deployment.
  3. allows servlets to query about MIME type of a specified file
  4. provides access to RequestDispatcher that allows one servlet to forward/include to other servlets or resources. it also allows dispatching to servlets based on their deployment names.
  5. allows access ,given a path, to a resource, as either URL or InputStream object, within the context of the web application. if for instance, there is an XML file that you want to read from the servlet, you can get InputStream object to it via ServletContext
  6. you can log servlet activities into the logger from ServletContext
About | Sitemap | Contact