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 java.lang.String[] defaultMethods
           
protected  boolean disableScript
           
protected  boolean displayResults
           
protected  java.lang.String[] languages
           
protected  java.lang.String[] methods
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
protected  java.lang.String scriptDir
           
protected  javax.servlet.Servlet servlet
           
protected  boolean useSession
           
 
Fields inherited from class javax.script.SimpleScriptContext
engineScope, globalScope
 
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(java.lang.String relativePath)
          Forwards the request to the resource identified by the specified relative path.
 java.lang.String[] getAllowedLanguages()
          Retrieves an array of Strings describing the languages that may be used by scripts which is running in the associated HttpScriptContext.
 java.lang.Object getAttribute(java.lang.String key, java.lang.Object value, int scope)
           
 java.lang.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.
 java.io.Reader getScriptSource()
          Retrieves a reader form which the executing script can be read.
 javax.servlet.Servlet getServlet()
          Retrieves the associated HttpScriptServlet.
 java.io.Writer getWriter()
          Retrieves an instance of java.io.Writer which can be used by scripts to display their output.
 void include(java.lang.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(java.lang.String key, java.lang.Object value, int scope)
          Sets an attribute specified by the name in specified level of 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 org.apache.bsf.utils.http.HttpScriptContext
getAttribute, getAttribute
 
Methods inherited from interface javax.script.ScriptContext
getAttributesScope, getBindings, getErrorWriter, getReader, getScopes, removeAttribute, setBindings, setErrorWriter, setReader, setWriter
 

Field Detail

defaultMethods

public static final java.lang.String[] defaultMethods

disableScript

protected boolean disableScript

displayResults

protected boolean displayResults

scriptDir

protected java.lang.String scriptDir

languages

protected java.lang.String[] languages

methods

protected java.lang.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 java.lang.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 java.lang.Object getAttribute(java.lang.String key,
                                     java.lang.Object value,
                                     int scope)

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value,
                         int scope)
                  throws java.lang.IllegalArgumentException
Description copied from class: SimpleScriptContext
Sets an attribute specified by the name in specified level of scope.

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

forward

public void forward(java.lang.String relativePath)
             throws javax.servlet.ServletException,
                    java.io.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
java.io.IOException - if an input or output error occurs while processing the HTTP request

getMethods

public java.lang.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 java.io.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(java.lang.String relativePath)
             throws javax.servlet.ServletException,
                    java.io.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
java.io.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 java.io.Writer getWriter()
Description copied from interface: ScriptContext
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-2009 Apache Software Foundation. All Rights Reserved.