Name

application

Synopsis

Variable Name:

application

Interface Name:

javax.servlet.ServletContext

Extends:

None

Implemented by:

Internal container-dependent class

JSP Page Type:

Available in both regular JSP pages and error pages

Description

The ServletContext provides resources shared within a web application. It holds attribute values representing the JSP application scope. An attribute value can be an instance of any valid Java class. It also defines a set of methods that a JSP page or a servlet uses to communicate with its container, for example, to get the MIME type of a file, dispatch requests, or write to a log file. The web container is responsible for providing an implementation of the ServletContext interface.

A ServletContext is assigned a specific URI path prefix within a web server. For example, a context could be responsible for all resources under http://www.mycorp.com/catalog. All requests that start with the /catalog request path, which is known as the context path, are routed to this servlet context.

Only one instance of a ServletContext may be available to the servlets and JSP pages in a web application. If the web application indicates that it is distributable, there must be only one instance of the ServletContext object in use per application per Java Virtual Machine.

Interface Declaration

public interface ServletContext { public Object getAttribute(String name); public Enumeration getAttributeNames( ); public ServletContext getContext(String uripath); public ...

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.