Expresso 5-6

com.jcorporate.expresso.core.servlet
Class DBServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.jcorporate.expresso.core.servlet.StdServlet
              extended bycom.jcorporate.expresso.core.servlet.DBServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig
Direct Known Subclasses:
DBCreate, InitServlet, PathHandler, Test, ViewHandler

public abstract class DBServlet
extends StdServlet

A Servlet set up to have access to a relational database from the server side. This is a base class for all database maintenance and reporting servlets

Author:
Michael Nash
See Also:
Serialized Form

Field Summary
protected static String thisClass
           
 
Fields inherited from class com.jcorporate.expresso.core.servlet.StdServlet
mySchema
 
Constructor Summary
DBServlet()
           
 
Method Summary
 void destroy()
          Implemented for when the context is unloaded.
 void doGet(HttpServletRequest request, HttpServletResponse response)
          Ancestor calls this function (with super.doGet) to handle making database connection, getting user login info and other common tasks
 void doPost(HttpServletRequest req, HttpServletResponse res)
          Ancestor calls this method via super.doPost to handle standard operations
protected  String getDBName(HttpServletRequest request)
          Return the "alternate" database name, if one is set.
 void init(ServletConfig sc)
          Standard Servlet init() function
 boolean requireLogin(HttpServletRequest req, HttpServletResponse res, String nextURL)
          Deprecated. does nothing but return false;
protected  void setDBName(String newDBName, HttpServletRequest req)
          Set the "alternate" database name
 void setSkipLogin(boolean newSkip)
           
 void setupChannels(HttpServletRequest req)
          Set up the logging channels for all DBServlets
 
Methods inherited from class com.jcorporate.expresso.core.servlet.StdServlet
getSchema, getServerName, getServerPort, getServletPrefix, getServletPrefix, getString, getString, getTitle, handleParam, setSchema, showError, showError
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
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

thisClass

protected static final String thisClass
Constructor Detail

DBServlet

public DBServlet()
Method Detail

init

public void init(ServletConfig sc)
          throws ServletException
Standard Servlet init() function

Specified by:
init in interface Servlet
Overrides:
init in class StdServlet
Parameters:
sc - The servlet Configuration passed by the web.xml file
Throws:
ServletException

destroy

public void destroy()
Implemented for when the context is unloaded.

Specified by:
destroy in interface Servlet
Overrides:
destroy in class StdServlet

doGet

public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
           throws ServletException,
                  IOException
Ancestor calls this function (with super.doGet) to handle making database connection, getting user login info and other common tasks

Overrides:
doGet in class StdServlet
Parameters:
request - Standard request object
response - Standard response object
Throws:
ServletException - If an uncaught exception occurs
IOException - If an I/O error communicating with the client occurs

doPost

public void doPost(HttpServletRequest req,
                   HttpServletResponse res)
            throws ServletException,
                   IOException
Ancestor calls this method via super.doPost to handle standard operations

Overrides:
doPost in class StdServlet
Parameters:
req - Standard request object
res - Standard response object
Throws:
ServletException - If an uncaught exception occurs
IOException - If an I/O error occurs communicating with the client

getDBName

protected String getDBName(HttpServletRequest request)
Return the "alternate" database name, if one is set. Else return an empty string

Parameters:
request - The servlet request
Returns:
The name of the specified alternate database

requireLogin

public boolean requireLogin(HttpServletRequest req,
                            HttpServletResponse res,
                            String nextURL)
                     throws IOException,
                            ServletException,
                            DBException,
                            LogException,
                            HtmlException
Deprecated. does nothing but return false;

Verify that the current user is logged in. If not, try to log in via the stored cookie. If that's not possible, log in as Anonymous

Parameters:
req - Standard request object
res - Standard response object
nextURL - to proceed with when login completed successfully
Returns:
true if login is required
Throws:
IOException - If an I/O error occurs communicating with the client
ServletException - If an uncaught exception occurs
DBException - If a problem occurs accessing login information in the database
LogException
HtmlException

setDBName

protected void setDBName(String newDBName,
                         HttpServletRequest req)
                  throws ServletException
Set the "alternate" database name

Parameters:
newDBName - The new data context to set the session for
req - the servlet request object
Throws:
ServletException

setSkipLogin

public void setSkipLogin(boolean newSkip)
Parameters:
newSkip - set to true if you want login processing skipped

setupChannels

public void setupChannels(HttpServletRequest req)
                   throws ServletException
Set up the logging channels for all DBServlets

Parameters:
req - The servlet request object
Throws:
ServletException

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.