| javax.script.http.HttpScriptContext
All known Subclasses: javax.script.http.SimpleHttpScriptContext,
HttpScriptContext | public interface HttpScriptContext extends ScriptContext(Code) | | Classes implementing the HttpScriptContext interface connect a
ScriptEngine with the implicit objects from a Servlet Container.
The interface contains methods that allow a HttpScriptServlet to initialize the
HttpScriptContext with the implicit objects for each request,
and methods that allow a ScriptEngine to access them.
The objects may be used by internal constructs related to the web environment in
the scripting languages, and are also generally exposed in the namespaces
of scripts executing in the engines.
|
Field Summary | |
final public static int | APPLICATION_SCOPE ApplicationScope attributes are visible during the processing
of all requests belonging to a single Web Application. | final public static int | REQUEST_SCOPE RequestScope attributes are visible during the processing
of a single request. | final public static int | SESSION_SCOPE SessionScope attributes are visible during the processing
of all requests belonging to a single HttpSession
during the lifetime of the session. |
Method Summary | |
public boolean | disableScript() Return value indicates whether script execution has been
disabled in the Web Application. | public boolean | displayResults() Return value indicates whether a HttpScriptServlet executing in this context
should display the results of script evaluations. If true , the
servlet should display the toString of the value returned by script execution using the
Writer returned by the getWriter method.
The value is determined by the script-display-results initialization parameter.
true unless the value of the script-display-results initialization parameter is "false". | public void | forward(String relativePath) Forward the request to the resource identified by the specified
relative path.
Parameters: relativePath - The URI to process the request. | public String[] | getAllowedLanguages() An array of Strings naming the languages that may be used by scripts running
in this HttpScriptContext . | public Object | getAttribute(String name, int scope) Gets the value of the attribute in the specified scope. | public Object | getAttribute(String name) Returns the value of the attribute in the lowest scope for which
the attribute is defined. | public String[] | getMethods() An array of Strings describing the HTTP request methods handled by
HttpScriptServlets executing in this context. | public HttpServletRequest | getRequest() Returns the HttpServoetRequest for the current request. | public HttpServletResponse | getResponse() Returns the HttpServletResponse for the current request. | public Reader | getScriptSource() Returns a Reader from which the source of the script used to execute the
current request can be read. | public Servlet | getServlet() Returns the HttpScriptServlet using the HttpScriptContext . | public void | include(String relativePath) Includes the resource identified by the specified
relative path.
Parameters: relativePath - The URI to process the request. | public void | initialize(Servlet servlet, HttpServletRequest req, HttpServletResponse res) Initializes this HttpScriptContext for processing of a single
request. | public void | release() Clears any state stored in this HttpScriptContext , allowing its
reuse by other requests. | public void | setAttribute(String name, Object value, int scope) Sets the value of the named attribute in the specified scope. | public boolean | useSession() Return value indicates whether the HttpSession associated
with the current request is exposed in the SESSION_SCOPE attributes and
in the HttpScriptRequest returned by getRequest .
This is determined by the value of the script-use-session Web Application
initialization parameter.
true unless the value of the script-use-session parameter is "false". |
APPLICATION_SCOPE | final public static int APPLICATION_SCOPE(Code) | | ApplicationScope attributes are visible during the processing
of all requests belonging to a single Web Application.
|
REQUEST_SCOPE | final public static int REQUEST_SCOPE(Code) | | RequestScope attributes are visible during the processing
of a single request.
|
SESSION_SCOPE | final public static int SESSION_SCOPE(Code) | | SessionScope attributes are visible during the processing
of all requests belonging to a single HttpSession
during the lifetime of the session.
|
disableScript | public boolean disableScript()(Code) | | Return value indicates whether script execution has been
disabled in the Web Application. This is determined by the value
of the application's initialization parameter script-disable.
false unless the value of that parameter is "true". Returns true in that case. |
displayResults | public boolean displayResults()(Code) | | Return value indicates whether a HttpScriptServlet executing in this context
should display the results of script evaluations. If true , the
servlet should display the toString of the value returned by script execution using the
Writer returned by the getWriter method.
The value is determined by the script-display-results initialization parameter.
true unless the value of the script-display-results initialization parameter is "false". Returns false in that case. |
forward | public void forward(String relativePath) throws ServletException, IOException(Code) | | Forward the request to the resource identified by the specified
relative path.
Parameters: relativePath - The URI to process the request. The path is resolved according to the rules specified in the forward method of javax.servlet.jsp.PageContext . throws: ServletException - |
getAllowedLanguages | public String[] getAllowedLanguages()(Code) | | An array of Strings naming the languages that may be used by scripts running
in this HttpScriptContext . The value is obtained from the
allow-languages initialization parameter. A return value of null
indicates that there is no restriction on script language.
An array of allowed script languages. |
getAttribute | public Object getAttribute(String name, int scope)(Code) | | Gets the value of the attribute in the specified scope. Initially, the
REQUEST_SCOPE , SESSION_SCOPE and
APPLICATION_SCOPE should be initialized using the values of the
request attributes, session attributes and context attributes associated
with the current request. Also, the following mappings should
be included in the initial values of the REQUEST_SCOPE attributes:
Name | Value |
Request | return value of getRequest |
Response | return value of getResponse |
Servlet | return value of getServlet |
Attempts to access SESSION_SCOPE
attributes should return null if useSession
returns false or if the current session is invalid.
Parameters: name - The name of the attribute to get Parameters: scope - The scope used to find the attribute the value of the attribute. throws: IllegalArgumentException - if scope is invalid. |
getAttribute | public Object getAttribute(String name)(Code) | | Returns the value of the attribute in the lowest scope for which
the attribute is defined. Return null if an attribute
with the given name is not defined in any scope.
|
getMethods | public String[] getMethods()(Code) | | An array of Strings describing the HTTP request methods handled by
HttpScriptServlets executing in this context. The value is determined
by the value of the script-methods Web Application initialization parameter.
An array of (case-insensitive) method names. The elements of the array are determined by the script-methods initialization parameter, which is a comma-delimited list of the names. |
getRequest | public HttpServletRequest getRequest()(Code) | | Returns the HttpServoetRequest for the current request. If the
use of session state is disabled using the script-use-session
initialization parameter, an adapter whose getSession method
returns null must be returned.
The current request |
getResponse | public HttpServletResponse getResponse()(Code) | | Returns the HttpServletResponse for the current request.
The current response |
getScriptSource | public Reader getScriptSource()(Code) | | Returns a Reader from which the source of the script used to execute the
current request can be read. This may be obtained from a resource in the current
Web Application whose name is derived from the URI of the current request, a
script directory in the filesystem specified in the configuration of the
Web Application or in some implementation-defined way.
|
getServlet | public Servlet getServlet()(Code) | | Returns the HttpScriptServlet using the HttpScriptContext .
The current servlet |
include | public void include(String relativePath) throws ServletException, IOException(Code) | | Includes the resource identified by the specified
relative path.
Parameters: relativePath - The URI to process the request. The path is resolved according to the rules specified in the include method of javax.servlet.jsp.PageContext . throws: ServletException - |
initialize | public void initialize(Servlet servlet, HttpServletRequest req, HttpServletResponse res) throws ServletException(Code) | | Initializes this HttpScriptContext for processing of a single
request. Implementations must initialize attributes in REQUEST_SCOPE ,
SESSION_SCOPE and APPLICATION_SCOPE
and store servlet, request and response references for use by the ScriptEngine
executing the request.
Parameters: servlet - The HttpScriptServlet executing the request Parameters: req - The current request. Parameters: res - The current response. throws: ServletException - If a ScriptExcepton is thrown by the ScriptEngine during the processing of a request. |
release | public void release()(Code) | | Clears any state stored in this HttpScriptContext , allowing its
reuse by other requests.
|
setAttribute | public void setAttribute(String name, Object value, int scope)(Code) | | Sets the value of the named attribute in the specified scope.
Calls using REQUEST_SCOPE , SESSION_SCOPE
and APPLICATION_SCOPE should set the corresponding
request attribute, session attribute or context attribute for the current request.
Parameters: name - The name of the attribute to set. Parameters: value - The value of the attribute to set. Parameters: scope - The scope in which to set the attribute. throws: IllegalArgumentException - if scope is invalid. throws: IllegalStateException - if scope is SESSION_SCOPE and session is either invalid or disabled according to the returnvalue of useSession . |
useSession | public boolean useSession()(Code) | | Return value indicates whether the HttpSession associated
with the current request is exposed in the SESSION_SCOPE attributes and
in the HttpScriptRequest returned by getRequest .
This is determined by the value of the script-use-session Web Application
initialization parameter.
true unless the value of the script-use-session parameter is "false". Returns false in that case. |
|
|