org.apache.bsf.utils.http
Class GenericHttpScriptContext

java.lang.Object
  extended by javax.script.SimpleScriptContext
      extended by org.apache.bsf.utils.http.GenericHttpScriptContext
All Implemented Interfaces:
ScriptContext, HttpScriptContext

public class GenericHttpScriptContext
extends SimpleScriptContext
implements HttpScriptContext


Field Summary
static String[] defaultMethods
           
protected  boolean disableScript
           
protected  boolean displayResults
           
protected  String[] languages
           
protected  String[] methods
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
protected  String scriptDir
           
protected  javax.servlet.Servlet servlet
           
protected  boolean useSession
           
 
Fields inherited from class javax.script.SimpleScriptContext
engineScope, errorWriter, globalScope, reader, writer
 
Fields inherited from interface org.apache.bsf.utils.http.HttpScriptContext
APPLICATION_SCOPE, REQUEST_SCOPE, SESSION_SCOPE
 
Fields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
 
Constructor Summary
GenericHttpScriptContext()
           
 
Method Summary
 boolean disableScript()
          Retrieves a boolean value which indicates whether the script execution has been disabled in the Web Application.
 boolean displayResults()
          Retrieves a boolean value which indicates whether the HttpScriptServlet executing in this context should display the results of script evaluations.
 void forward(String relativePath)
          Forwards the request to the resource identified by the specified relative path.
 String[] getAllowedLanguages()
          Retrieves an array of Strings describing the languages that may be used by scripts which is running in the associated HttpScriptContext.
 Object getAttribute(String key, Object value, int scope)
           
 String[] getMethods()
          Retrieves an array of string describing HTTP request methods which are handled by servlets executing in current context.
 javax.servlet.http.HttpServletRequest getRequest()
          Retrieves a HttpScriptRequest for the current request.
 javax.servlet.http.HttpServletResponse getResponse()
          Retrieves a HttpScriptResponse for the current request.
 Reader getScriptSource()
          Retrieves a reader form which the executing script can be read.
 javax.servlet.Servlet getServlet()
          Retrieves the associated HttpScriptServlet.
 Writer getWriter()
          Retrieves an instance of java.io.Writer which can be used by scripts to display their output.
 void include(String relativePath)
          Includes the resource in the sepcified relative path.
 void initialize(javax.servlet.Servlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Initialize the current HttpScriptContext for processing of single request.
 void release()
          Clears any state stored in the current HttpScriptContext such that it can be reused to serve another request.
 void setAttribute(String key, Object value, int scope)
          Associates a specified value with the specifed name in the specified scope.
 boolean useSession()
          Retrieves a boolean value which indicates whether the HttpSession associated with the current request is exposed in SESSION_SCOPE attribute and in the HttpScriptRequest.
 
Methods inherited from class javax.script.SimpleScriptContext
getAttribute, getAttribute, getAttributesScope, getBindings, getErrorWriter, getReader, getScopes, removeAttribute, setBindings, setErrorWriter, setReader, setWriter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.script.ScriptContext
getAttribute, getAttribute, getAttributesScope, getBindings, getErrorWriter, getReader, getScopes, removeAttribute, setBindings, setErrorWriter, setReader, setWriter
 

Field Detail

defaultMethods

public static final String[] defaultMethods

disableScript

protected boolean disableScript

displayResults

protected boolean displayResults

scriptDir

protected String scriptDir

languages

protected String[] languages

methods

protected String[] methods

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

servlet

protected javax.servlet.Servlet servlet

useSession

protected boolean useSession
Constructor Detail

GenericHttpScriptContext

public GenericHttpScriptContext()
Method Detail

disableScript

public boolean disableScript()
Description copied from interface: HttpScriptContext
Retrieves a boolean value which indicates whether the script execution has been disabled in the Web Application.

Specified by:
disableScript in interface HttpScriptContext
Returns:
a booean indicating whether the script execution is allowed

displayResults

public boolean displayResults()
Description copied from interface: HttpScriptContext
Retrieves a boolean value which indicates whether the HttpScriptServlet executing in this context should display the results of script evaluations.

Specified by:
displayResults in interface HttpScriptContext
Returns:
a boolean indicating whether the results of script eveluations should be displayed

getAllowedLanguages

public String[] getAllowedLanguages()
Description copied from interface: HttpScriptContext
Retrieves an array of Strings describing the languages that may be used by scripts which is running in the associated HttpScriptContext. Returns null if no restrictions apply.

Specified by:
getAllowedLanguages in interface HttpScriptContext
Returns:
a String array of permitted languages

getAttribute

public Object getAttribute(String key,
                           Object value,
                           int scope)

setAttribute

public void setAttribute(String key,
                         Object value,
                         int scope)
                  throws IllegalArgumentException
Description copied from class: SimpleScriptContext
Associates a specified value with the specifed name in the specified scope.

Specified by:
setAttribute in interface ScriptContext
Overrides:
setAttribute in class SimpleScriptContext
Parameters:
key - the name of the attribute
value - the value of the attribute
scope - the scope
Throws:
IllegalArgumentException - if the name is null or the scope is invalid

forward

public void forward(String relativePath)
             throws javax.servlet.ServletException,
                    IOException
Description copied from interface: HttpScriptContext
Forwards the request to the resource identified by the specified relative path.

Specified by:
forward in interface HttpScriptContext
Parameters:
relativePath - the URI to process the request
Throws:
javax.servlet.ServletException - if the HTTP cannot be handled
IOException - if an input or output error occurs while processing the HTTP request

getMethods

public String[] getMethods()
Description copied from interface: HttpScriptContext
Retrieves an array of string describing HTTP request methods which are handled by servlets executing in current context.

Specified by:
getMethods in interface HttpScriptContext
Returns:
a String array of HTTP request methods handled by servelts in the current context

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Description copied from interface: HttpScriptContext
Retrieves a HttpScriptRequest for the current request. If the session state is disabled, an adapter whose getSession() method returns null should be used.

Specified by:
getRequest in interface HttpScriptContext
Returns:
the current request

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Description copied from interface: HttpScriptContext
Retrieves a HttpScriptResponse for the current request.

Specified by:
getResponse in interface HttpScriptContext
Returns:
the current response

getScriptSource

public Reader getScriptSource()
Description copied from interface: HttpScriptContext
Retrieves a reader form which the executing script can be read.

Specified by:
getScriptSource in interface HttpScriptContext
Returns:
a reader from which the script can be read.

getServlet

public javax.servlet.Servlet getServlet()
Description copied from interface: HttpScriptContext
Retrieves the associated HttpScriptServlet.

Specified by:
getServlet in interface HttpScriptContext
Returns:
a reader form which the script source can be read

include

public void include(String relativePath)
             throws javax.servlet.ServletException,
                    IOException
Description copied from interface: HttpScriptContext
Includes the resource in the sepcified relative path.

Specified by:
include in interface HttpScriptContext
Parameters:
relativePath - the URI of the request to be processed
Throws:
javax.servlet.ServletException - if the servlet cannot handled the HTTP request
IOException - if an input or output error occurs while processing the HTTP request

initialize

public void initialize(javax.servlet.Servlet servlet,
                       javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
                throws javax.servlet.ServletException
Description copied from interface: HttpScriptContext
Initialize the current HttpScriptContext for processing of single request. Implementation must initialize request, session and application scopes. Further it should store servlet, request and response references for use.

Specified by:
initialize in interface HttpScriptContext
Parameters:
servlet - the HttpServlet which execute the request
request - the current request
response - the current response
Throws:
javax.servlet.ServletException - if the servlet cannot handle the HTTP request

release

public void release()
Description copied from interface: HttpScriptContext
Clears any state stored in the current HttpScriptContext such that it can be reused to serve another request.

Specified by:
release in interface HttpScriptContext

useSession

public boolean useSession()
Description copied from interface: HttpScriptContext
Retrieves a boolean value which indicates whether the HttpSession associated with the current request is exposed in SESSION_SCOPE attribute and in the HttpScriptRequest.

Specified by:
useSession in interface HttpScriptContext
Returns:
a boolean value which indicates whether the session is vaild

getWriter

public Writer getWriter()
Description copied from class: SimpleScriptContext
Retrieves an instance of java.io.Writer which can be used by scripts to display their output.

Specified by:
getWriter in interface ScriptContext
Overrides:
getWriter in class SimpleScriptContext
Returns:
an instance of java.io.Writer


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.