org.restafarian.core.servlets
Class JavascriptServletBase

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.restafarian.core.servlets.JavascriptServletBase
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public abstract class JavascriptServletBase
extends javax.servlet.http.HttpServlet

This is the base class for all of the Javascript servlets.

See Also:
Serialized Form

Field Summary
protected  javax.servlet.ServletContext context
           
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
JavascriptServletBase()
           
 
Method Summary
abstract  void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "doGet()" method.
protected static java.lang.String filter(java.lang.String value)
          Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities.
protected  java.lang.String getIdFromUrl(javax.servlet.http.HttpServletRequest req, java.lang.String servletPath)
          Returns the id present in the URL, if any.
protected  java.lang.String getNameSpaceUrl(javax.servlet.http.HttpServletRequest req)
          Returns the name space url.
protected  void sendError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int errorCode, java.lang.String errorMessage)
          Sends the HTTP error code and message, and logs the code and message if enabled.
protected  void sendError(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, int errorCode, java.lang.String errorMessage, java.lang.Throwable throwable)
          Sends the HTTP error code and message, and logs the code and message if enabled.
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          The Servlet "service" method.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
 
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
 

Field Detail

context

protected javax.servlet.ServletContext context

log

protected org.apache.commons.logging.Log log
Constructor Detail

JavascriptServletBase

public JavascriptServletBase()
Method Detail

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
             throws javax.servlet.ServletException,
                    java.io.IOException

The Servlet "service" method.

Overrides:
service in class javax.servlet.http.HttpServlet
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

doGet

public abstract void doGet(javax.servlet.http.HttpServletRequest req,
                           javax.servlet.http.HttpServletResponse res)
                    throws javax.servlet.ServletException,
                           java.io.IOException

The Servlet "doGet()" method.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
Throws:
javax.servlet.ServletException
java.io.IOException

getIdFromUrl

protected java.lang.String getIdFromUrl(javax.servlet.http.HttpServletRequest req,
                                        java.lang.String servletPath)

Returns the id present in the URL, if any.

Parameters:
req - the HttpServletRequest object
servletPath - the path to the servlet, including both the leading and trailing "/"
Returns:
the id present in the URL, if any

getNameSpaceUrl

protected java.lang.String getNameSpaceUrl(javax.servlet.http.HttpServletRequest req)

Returns the name space url.

Parameters:
req - the HttpServletRequest object
Returns:
the name space url

filter

protected static java.lang.String filter(java.lang.String value)
Filter the specified string for characters that are sensitive to HTML interpreters, returning the string with these characters replaced by the corresponding character entities. Lifted from Struts ResponseUtils

Parameters:
value - The string to be filtered and returned
Returns:
The filtered string

sendError

protected void sendError(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res,
                         int errorCode,
                         java.lang.String errorMessage)
                  throws java.io.IOException

Sends the HTTP error code and message, and logs the code and message if enabled.

Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
errorCode - the error code to send
errorMessage - the error message to send
Throws:
java.io.IOException

sendError

protected void sendError(javax.servlet.http.HttpServletRequest req,
                         javax.servlet.http.HttpServletResponse res,
                         int errorCode,
                         java.lang.String errorMessage,
                         java.lang.Throwable throwable)
                  throws java.io.IOException

Sends the HTTP error code and message, and logs the code and message if enabled.

Parameters:
req - the HttpServletRequest object
res - the HttpServletResponse object
errorCode - the error code to send
errorMessage - the error message to send
throwable - an optional exception
Throws:
java.io.IOException


Copyright © 2008. All Rights Reserved.