APIdia Launch Partner
Top Description Constructors Methods
com.sun.net.httpserver

public abstract Class HttpContext

extends Object
Class Inheritance
Known Direct Subclasses
sun.net.httpserver.HttpContextImpl
Imports
java.util.List, .Map

HttpContext represents a mapping between the root java.net.URI path of an application to a HttpHandler which is invoked to handle requests destined for that path on the associated HttpServer or HttpsServer.

HttpContext instances are created by the create methods in HttpServer and HttpsServer.

A chain of Filter objects can be added to a HttpContext. All exchanges processed by the context can be pre- and post-processed by each Filter in the chain.

Since
1.6

Constructor Summary

AccessConstructor and Description
protected
HttpContext()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract Map<String, Object>

Returns:

a Map containing the attributes of this context
getAttributes
()

Returns a mutable Map, which can be used to pass configuration and other data to Filter modules and to the context's exchange handler.

public abstract Authenticator

Returns:

this HttpContext's Authenticator, or null if none is set
getAuthenticator
()

Returns the currently set Authenticator for this context if one exists.

public abstract List<Filter>

Returns:

a List containing the filters of this context
getFilters
()

Returns this context's List of filters.

public abstract HttpHandler

Returns:

the HttpHandler for this context
getHandler
()

Returns the handler for this context.

public abstract String

Returns:

the context of this path
getPath
()

Returns the path this context was created with.

public abstract HttpServer

Returns:

the context of this server
getServer
()

Returns the server this context was created with.

public abstract Authenticator

Returns:

the previous Authenticator, if any set, or null otherwise.
setAuthenticator
(Authenticator
the Authenticator to set. If null then any previously set Authenticator is removed, and client authentication will no longer be required.
auth
)

Sets the Authenticator for this HttpContext.

public abstract void
setHandler(HttpHandler
the handler to set for this context
handler
)

Sets the handler for this context, if not already set.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HttpContextback to summary
protected HttpContext()

Constructor for subclasses to call.

Method Detail

getAttributesback to summary
public abstract Map<String, Object> getAttributes()

Returns a mutable Map, which can be used to pass configuration and other data to Filter modules and to the context's exchange handler.

Every attribute stored in this Map will be visible to every HttpExchange processed by this context.

Returns:Map<String, Object>

a Map containing the attributes of this context

getAuthenticatorback to summary
public abstract Authenticator getAuthenticator()

Returns the currently set Authenticator for this context if one exists.

Returns:Authenticator

this HttpContext's Authenticator, or null if none is set

getFiltersback to summary
public abstract List<Filter> getFilters()

Returns this context's List of filters. This is the actual list used by the server when dispatching requests so modifications to this list immediately affect the handling of exchanges.

Returns:List<Filter>

a List containing the filters of this context

getHandlerback to summary
public abstract HttpHandler getHandler()

Returns the handler for this context.

Returns:HttpHandler

the HttpHandler for this context

getPathback to summary
public abstract String getPath()

Returns the path this context was created with.

Returns:String

the context of this path

getServerback to summary
public abstract HttpServer getServer()

Returns the server this context was created with.

Returns:HttpServer

the context of this server

setAuthenticatorback to summary
public abstract Authenticator setAuthenticator(Authenticator auth)

Sets the Authenticator for this HttpContext. Once an authenticator is established on a context, all client requests must be authenticated, and the given object will be invoked to validate each request. Each call to this method replaces any previous value set.

Parameters
auth:Authenticator

the Authenticator to set. If null then any previously set Authenticator is removed, and client authentication will no longer be required.

Returns:Authenticator

the previous Authenticator, if any set, or null otherwise.

setHandlerback to summary
public abstract void setHandler(HttpHandler handler)

Sets the handler for this context, if not already set.

Parameters
handler:HttpHandler

the handler to set for this context

Exceptions
IllegalArgumentException:
if the context for this handler is already set.
NullPointerException:
if handler is null