OpMath

com.opmath.util.http
Class HttpProtectedServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.opmath.util.http.HttpServlet
                    |
                    +--com.opmath.util.http.HttpProtectedServlet
All Implemented Interfaces:
ParamIndex, Serializable, Servlet, ServletConfig

public abstract class HttpProtectedServlet
extends HttpServlet
implements ParamIndex

Provides an abstract class for protected servlets.

Protcted servlets are those that require that the requester has been authenticated and authorised, and has thereby established a session. This class has to deal with two distinct outcomes, in response to a request to a protected servlet:

WARNING: It is up to the programmer to ensure that the use of the HttpSession instance variable (or any other instance variable) has thread safety.

Copyright: (c) 2002 The Open Math Company Limited

The Terms of Distribution of this software are stipulated in the javadoc Overview for this project.

Since:
J2SE 1.3.0
Version:
utilities-v011
Author:
Bruno Beloff bruno.beloff@opmath.com
See Also:
HttpServlet, HttpSessionServlet, HttpLogOnServlet, HttpLogOffServlet, Serialized Form

Fields inherited from class com.opmath.util.http.HttpServlet
EOL, LOGON_ID, LOGON_TARGET
 
Constructor Summary
HttpProtectedServlet()
           
 
Method Summary
 void doGet(HttpServletRequest req, HttpServletResponse rsp)
          Handles an HTTP GET request.
protected  String doGetDispatch(HttpServletRequest req)
          Services an HTTP GET request, as handled by the doGet(HttpServletRequest, HttpServletResponse) method on this class.
 void doPost(HttpServletRequest req, HttpServletResponse rsp)
          Handles an HTTP POST request.
protected  String doPostDispatch(HttpServletRequest req)
          Services an HTTP POST request, as handled by the doPost(HttpServletRequest, HttpServletResponse) method on this class.
 String getServletInfo()
          Returns a String carrying some information about the servlet.
protected  String protectedRedirectURI()
          Returns the URI of the resource that provides a log on function.
 
Methods inherited from class com.opmath.util.http.HttpServlet
getIndex, getParamIndex, getValueCount, paramIndices, paramMappings, paramNames, paramValues, registerIndex, registerIndices, report, setConfig, setConfig
 
Methods inherited from class javax.servlet.http.HttpServlet
, doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.opmath.util.http.ParamIndex
getIndex, getParamIndex, getValueCount, paramIndices, paramMappings, paramNames, paramValues, registerIndex
 

Constructor Detail

HttpProtectedServlet

public HttpProtectedServlet()
Method Detail

protectedRedirectURI

protected String protectedRedirectURI()

Returns the URI of the resource that provides a log on function. Invoked when an attempt is made to access a protected servlet, by a requester that does not have a current session.

The URI String returned is "/logon".

Returns:
A String carrying the default redirection URI.
Since:
J2SE 1.3

doGet

public final void doGet(HttpServletRequest req,
                        HttpServletResponse rsp)
                 throws ServletException,
                        IOException

Handles an HTTP GET request. This method will either redirect the requester to the log on resource, or hand over to the appropriate doGetDispatch(com.opmath.util.http.HttpServletRequest) method.

Specified as final to maintain security.

Overrides:
doGet in class HttpServlet
Parameters:
req - an HttpServletRequest object that contains the request the client has made of the servlet.
rsp - an HttpServletResponse object that contains the response the servlet sends to the client.
Throws:
ServletException - an exception thrown if the request could not be handled.
IOException - an exception thrown if an input or output error is detected when the servlet handles the GET request.
Since:
J2SE 1.3
See Also:
doGetDispatch(com.opmath.util.http.HttpServletRequest)

doGetDispatch

protected String doGetDispatch(HttpServletRequest req)
                        throws Exception

Services an HTTP GET request, as handled by the doGet(HttpServletRequest, HttpServletResponse) method on this class. This method should be overriden by any real-world application.

Overrides:
doGetDispatch in class HttpServlet
Parameters:
req - an com.opmath.util.http.HttpServletRequest created by doGet(HttpServletRequest, HttpServletResponse).
Returns:
A String carrying the report.
Throws:
Exception - if a subclass's method encounters any error state.
Since:
J2SE 1.3
See Also:
doGet(HttpServletRequest, HttpServletResponse)

doPost

public final void doPost(HttpServletRequest req,
                         HttpServletResponse rsp)
                  throws ServletException,
                         IOException

Handles an HTTP POST request. This method will either redirect the requester to the log on resource, or hand over to the appropriate doPostDispatch(com.opmath.util.http.HttpServletRequest) method.

Specified as final to maintain security.

Overrides:
doPost in class HttpServlet
Parameters:
req - an HttpServletRequest object that contains the request the client has made of the servlet.
rsp - an HttpServletResponse object that contains the response the servlet sends to the client.
Throws:
ServletException - an exception thrown if the request could not be handled.
IOException - an exception thrown if an input or output error is detected when the servlet handles the POST request.
Since:
J2SE 1.3
See Also:
doPostDispatch(com.opmath.util.http.HttpServletRequest)

doPostDispatch

protected String doPostDispatch(HttpServletRequest req)
                         throws Exception

Services an HTTP POST request, as handled by the doPost(HttpServletRequest, HttpServletResponse) method on this class. This method should be overriden by any real-world application.

Overrides:
doPostDispatch in class HttpServlet
Parameters:
req - an com.opmath.util.http.HttpServletRequest created by doGet(HttpServletRequest, HttpServletResponse).
Returns:
A String carrying the report.
Throws:
Exception - if a subclass's method encounters any error state.
Since:
J2SE 1.3
See Also:
doPost(HttpServletRequest, HttpServletResponse)

getServletInfo

public String getServletInfo()
Returns a String carrying some information about the servlet. This method should be overridden by any subclass.

Overrides:
getServletInfo in class HttpServlet
Returns:
a String describing the class.
Since:
J2SE 1.3

OpMath

Submit a bug or feature to Open Math
Copyright © 2002 Open Math Company Limited, Brighton, UK