|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--org.locomotive.loco.servlet.LocoServlet
The LocoServlet class is a Servlet class you can use as a superclass for Servlets you're writing to use with the Locomotive. It provides most of the same functionality as the GenericHandler class. Notice that it implements SingleThreadModel, which means you can safely store stuff in instance variables of your subclasses, making it easier to pass information between methods during a request.
There are two alternative ways to use this class:
GenericHandler
, Serialized FormField Summary | |
protected java.sql.Connection |
conn
The database connection this request can use, if desired. |
static int |
DEBUG
log level to use for debugging |
static int |
ERROR
Log level to use for serious errors; e.g. |
protected FormData |
form_data
the FormData object that contains any form information from a POST. |
static int |
NORMAL
log level to use for normal activities |
protected LocoServletRequest |
req
The request object we received for this request |
protected javax.servlet.http.HttpServletResponse |
resp
The response object to use for this request |
protected Session |
session
the session associated with this request. |
protected java.util.Hashtable |
steam_vars
the substitutions hashtable to be used when evaluating templates. |
protected java.lang.String[] |
url_tokens
the url tokens for this request. |
protected User |
user
the user associated with this request. |
static int |
WARNING
Log level to use for warnings |
Constructor Summary | |
LocoServlet()
|
Method Summary | |
java.lang.String |
displayPage(java.lang.String document_path,
java.util.Hashtable steam_vars)
loads a Steam document, inserts the values of Steam variables into that document, and then writes the result back to the Web server. |
void |
displayString(java.lang.String message)
if you want to send back a single string as the response to the user, you can use this method. |
void |
handleException(java.lang.Exception exception,
java.lang.String short_code)
this is a convenience method you can use when you catch serious Exceptions for which you want a stack trace and you need to send the user an error code, which can help you debug. |
void |
log(int log_level,
java.lang.String log_message)
writes a message to the locomotive's global server log. |
void |
logEvent(java.lang.String major,
java.lang.String minor,
java.lang.String data)
write one event to the global locomotive event log. |
void |
sayBadURL()
simply tells the user that they typed a bad URL, by sending the message: "I'm sorry, I don't understand that URL." |
void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
The service method is the main entry point for Servlets. |
void |
setup(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
This will set up the various fields the class requires. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete,
doGet,
doOptions,
doPost,
doPut,
doTrace,
getLastModified,
service |
Methods inherited from class javax.servlet.GenericServlet |
destroy,
getInitParameter,
getInitParameterNames,
getServletConfig,
getServletContext,
getServletInfo,
init,
init,
log,
log |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected LocoServletRequest req
protected javax.servlet.http.HttpServletResponse resp
protected java.lang.String[] url_tokens
protected FormData form_data
protected java.util.Hashtable steam_vars
protected User user
protected Session session
protected java.sql.Connection conn
public static final int ERROR
public static final int WARNING
public static final int NORMAL
public static final int DEBUG
Constructor Detail |
public LocoServlet()
Method Detail |
public void setup(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException, javax.servlet.ServletException
service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
public void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws java.io.IOException, javax.servlet.ServletException
If you choose to override this method in a sub class, don't forget to call the setup() method at the beginning of your version.
setup(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
,
javax.servlet.http.HttpServlet.html#service
public void log(int log_level, java.lang.String log_message)
log_level
- 0 is most severe. The higher, the less severe.
Messages with log_levels higher than the variable LOG_LEVEL (from
the file loco.conf) will be suppressed from being written to the log.log_message
- the message to write to the log.public void handleException(java.lang.Exception exception, java.lang.String short_code)
exception
- the exception to print to the server log.short_code
- the error message to send to the userpublic void logEvent(java.lang.String major, java.lang.String minor, java.lang.String data)
example:
logEvent (5, "login", "submit_form", user.getUsername());
major
- the major event region or code sectionminor
- the minor event codedata
- event specific datapublic void displayString(java.lang.String message) throws java.io.IOException
public java.lang.String displayPage(java.lang.String document_path, java.util.Hashtable steam_vars) throws java.io.IOException
document_path
- -- the file path of that document, relative to the
template root.public void sayBadURL() throws java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |