org.apache.bsf.utils.http
Class HttpScriptServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by org.apache.bsf.utils.http.HttpScriptServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class HttpScriptServlet
extends javax.servlet.GenericServlet

HttpScriptServlet contains method which allows execution of scripts written in one or more languages. It uses a ScriptEngine supplied by calling its getEngine method to execute a script in a HttpScriptContext supplied by calling its getContext method.

Author:
Nandika Jayawardana , Sanka Samaranayake
See Also:
Serialized Form

Constructor Summary
HttpScriptServlet()
           
 
Method Summary
 HttpScriptContext getContext(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Retrieves a HttpScriptContext initialized using specified HttpServletRequest, HttpServletResponse and a reference to this HttpScriptServlet.
 ScriptEngine getEngine(javax.servlet.http.HttpServletRequest req)
          Returns a ScriptEngine instance which is used by the HttpScriptServlet to executes a single request.
 void releaseEngine(ScriptEngine eng)
          Called to indicate that the ScriptEngine returned by call to getEngine() is no longer in use.
 void service(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res)
          Executes a script using the HttpScriptContext obtained by a call to getContext() and the ScriptEngine obtained by a call to getEngine().
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpScriptServlet

public HttpScriptServlet()
Method Detail

getContext

public HttpScriptContext getContext(javax.servlet.http.HttpServletRequest req,
                                    javax.servlet.http.HttpServletResponse res)
                             throws javax.servlet.ServletException
Retrieves a HttpScriptContext initialized using specified HttpServletRequest, HttpServletResponse and a reference to this HttpScriptServlet.

Parameters:
req - the supplied HttpServletRequest instance
res - the supplied HttpServletResponse instance
Returns:
an initialized HttpScriptContext
Throws:
javax.servlet.ServletException - if an error occurs

getEngine

public ScriptEngine getEngine(javax.servlet.http.HttpServletRequest req)
Returns a ScriptEngine instance which is used by the HttpScriptServlet to executes a single request.

Parameters:
req - the current request
Returns:
an instance of a ScriptEngine which is used by the HttpScriptServlet to executes a single request

releaseEngine

public void releaseEngine(ScriptEngine eng)
Called to indicate that the ScriptEngine returned by call to getEngine() is no longer in use.

Parameters:
eng - the ScriptEngine which is no longer in use

service

public void service(javax.servlet.ServletRequest req,
                    javax.servlet.ServletResponse res)
             throws java.lang.IllegalArgumentException,
                    java.io.IOException,
                    javax.servlet.ServletException
Executes a script using the HttpScriptContext obtained by a call to getContext() and the ScriptEngine obtained by a call to getEngine().

Specified by:
service in interface javax.servlet.Servlet
Specified by:
service in class javax.servlet.GenericServlet
Parameters:
req - the current request
res - the current response
Throws:
IlleagalArguementException - if the req is not an instance of HttpServletRequest or if the res is not an instance of HttpServletResponse
java.io.IOException - if an input, output error occurs
javax.servlet.ServletException - if error occurs in processing the request
java.lang.IllegalArgumentException


Copyright © 1999-2008 Apache Software Foundation. All Rights Reserved.