com.veriplace.web.servlet
Class AbstractVeriplaceServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.veriplace.web.servlet.AbstractVeriplaceServlet
All Implemented Interfaces:
java.io.Serializable, Servlet, ServletConfig

public abstract class AbstractVeriplaceServlet
extends HttpServlet

Base class for servlets that use Veriplace APIs.

Deriving from this class allows you to access Veriplace user/location data as follows:

You may attach the following init-params to your servlet in web.xml:

See Also:
Serialized Form

Field Summary
protected  java.lang.String defaultViewName
           
protected  Veriplace veriplace
           
 
Constructor Summary
AbstractVeriplaceServlet()
           
 
Method Summary
protected  void doGet(HttpServletRequest request, HttpServletResponse response)
           
protected  void doGetOrPost(HttpServletRequest request, HttpServletResponse response)
           
protected  void doPost(HttpServletRequest request, HttpServletResponse response)
           
protected  void doRequestInternal(HttpServletRequest request, HttpServletResponse response, VeriplaceState veriplaceState)
          Override this method to implement your request handler.
protected  void doRequestInternal(HttpServletRequest request, HttpServletResponse response, Veriplace veriplace, VeriplaceState veriplaceState)
          Override this method to implement your request handler.
protected  java.util.Properties getProperties()
          Returns the contents of the properties file specified in the "veriplace.properties-file" servlet context parameter in web.xml.
protected  Client getVeriplaceClient(HttpServletRequest request, Veriplace defaultInstance)
          Override this method if you might need to use a different Veriplace Client for some requests.
 void init(ServletConfig config)
          Initialize the client.
protected  void setupVeriplaceState(HttpServletRequest request, VeriplaceState state)
          Override this method if you need to change any properties of the VeriplaceState, such as VeriplaceState.setLocationMode(String), based on properties of the current request.
 
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, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

veriplace

protected Veriplace veriplace

defaultViewName

protected java.lang.String defaultViewName
Constructor Detail

AbstractVeriplaceServlet

public AbstractVeriplaceServlet()
Method Detail

init

public void init(ServletConfig config)
          throws ServletException
Initialize the client.

Specified by:
init in interface Servlet
Overrides:
init in class GenericServlet
Throws:
ServletException

doGet

protected void doGet(HttpServletRequest request,
                     HttpServletResponse response)
              throws ServletException,
                     java.io.IOException
Overrides:
doGet in class HttpServlet
Throws:
ServletException
java.io.IOException

doPost

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response)
               throws ServletException,
                      java.io.IOException
Overrides:
doPost in class HttpServlet
Throws:
ServletException
java.io.IOException

doGetOrPost

protected void doGetOrPost(HttpServletRequest request,
                           HttpServletResponse response)
                    throws ServletException,
                           java.io.IOException
Throws:
ServletException
java.io.IOException

doRequestInternal

protected void doRequestInternal(HttpServletRequest request,
                                 HttpServletResponse response,
                                 VeriplaceState veriplaceState)
                          throws java.io.IOException,
                                 ServletException,
                                 VeriplaceException
Override this method to implement your request handler.

This method will be called for both GET and POST requests. If you need to distinguish between GET and POST, check the properties of the HttpServletRequest; however, be aware that an operation that starts out as a POST may come back as a GET, if you went through a redirect/callback process for location discovery.

The base class implementation of this method simply forwards the request to the page specified in init-params as veriplace.defaultview.

Throws:
java.io.IOException
ServletException
VeriplaceException

doRequestInternal

protected void doRequestInternal(HttpServletRequest request,
                                 HttpServletResponse response,
                                 Veriplace veriplace,
                                 VeriplaceState veriplaceState)
                          throws java.io.IOException,
                                 ServletException,
                                 VeriplaceException
Override this method to implement your request handler. This version provides the current Veriplace instance as a convenience.

This method will be called for both GET and POST requests. If you need to distinguish between GET and POST, check the properties of the HttpServletRequest; however, be aware that an operation that starts out as a POST may come back as a GET, if you went through a redirect/callback process for location discovery.

The base class implementation of this method simply forwards the request to the page specified in init-params as veriplace.defaultview.

Throws:
java.io.IOException
ServletException
VeriplaceException

getVeriplaceClient

protected Client getVeriplaceClient(HttpServletRequest request,
                                    Veriplace defaultInstance)
                             throws ConfigurationException,
                                    UnexpectedException
Override this method if you might need to use a different Veriplace Client for some requests. For instance, you might use the same servlet to handling requests for more than one Veriplace application, each with its own consumer key and token. A Client is a fairly lightweight object, so it's acceptable to create a new one for each request if you want to.

Throws:
ConfigurationException
UnexpectedException

setupVeriplaceState

protected void setupVeriplaceState(HttpServletRequest request,
                                   VeriplaceState state)
                            throws VeriplaceException
Override this method if you need to change any properties of the VeriplaceState, such as VeriplaceState.setLocationMode(String), based on properties of the current request.

Throws:
VeriplaceException

getProperties

protected java.util.Properties getProperties()
                                      throws ConfigurationException
Returns the contents of the properties file specified in the "veriplace.properties-file" servlet context parameter in web.xml. This allows you to access non-Veriplace-related properties that you may wish to have in the same file for convenience.

Throws:
ConfigurationException - if the properties file was not specified or can't be read