com.groiss.servlet
Class Dispatcher

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.groiss.servlet.Dispatcher
All Implemented Interfaces:
Public, Serializable, Servlet, ServletConfig

public class Dispatcher
extends HttpServlet
implements Public

This servlet calls methods via reflection.

See Also:
Serialized Form

Field Summary
static com.groiss.servlet.impl.OldRequestHandler oldHandler
           
 
Constructor Summary
Dispatcher()
           
 
Method Summary
static void addModificationInfo(HttpServletRequest req, HttpServletResponse resp, long lastModified, Locale locale)
          adds some header fields to the response so we can determine modification on the next request
adds an ETag and a Last-Modified-Header
static Locale getBrowserLocale(HttpServletRequest req)
          Read the locale from the browser.
static String getContextPath()
          Returns the context path of this application.
static Method getMethod(String m)
          Return the method from a string containing the class and method name, syntax: classname "." methodname
static long getRequestCount()
          Get the request count for statistics.
 void init()
           
static boolean isModifiedSince(HttpServletRequest req, HttpServletResponse resp, long lastModified, Locale l)
          returns true if the requested resource has been modified since the last request
the following methods are used: check the ETag-header check the if-modified-since - header
static void reloadClasses()
          Reload the method cache the Dispatcher holds.
 void service(HttpServletRequest req, HttpServletResponse res)
           
static void setExpiresImmediatelyForGuest(HttpServletRequest req, HttpServletResponse res)
          if no user is currently logged in, it's required, that some resources are not cached, so the user gets the new files as soon he loggs in
static Locale setLocale(HttpServletRequest req)
          Set the locale to the ThreadContext.
 void setPathInfo(String pi)
          This method is useful if you call the dispatcher servlet from a method already called by the dispatcher.
static void writeToResp(HttpServletResponse res, String pageStr)
           
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, 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

oldHandler

public static com.groiss.servlet.impl.OldRequestHandler oldHandler
Constructor Detail

Dispatcher

public Dispatcher()
Method Detail

init

public void init()
Overrides:
init in class GenericServlet

setPathInfo

public void setPathInfo(String pi)
This method is useful if you call the dispatcher servlet from a method already called by the dispatcher.

Parameters:
pi - s string defining the method to call in form classname "." methodname

service

public void service(HttpServletRequest req,
                    HttpServletResponse res)
             throws IOException,
                    UnsupportedEncodingException
Overrides:
service in class HttpServlet
Throws:
IOException
UnsupportedEncodingException

writeToResp

public static void writeToResp(HttpServletResponse res,
                               String pageStr)
                        throws Exception
Throws:
Exception

getRequestCount

public static long getRequestCount()
Get the request count for statistics.

Returns:
the counter, starting with 0 on startup.

getMethod

public static Method getMethod(String m)
                        throws Exception
Return the method from a string containing the class and method name, syntax: classname "." methodname

Parameters:
m -
Returns:
the method object
Throws:
Exception - an exception is thrown if the string describes not a method with the signature necessary for the dispatcher.

reloadClasses

public static void reloadClasses()
Reload the method cache the Dispatcher holds.


setLocale

public static Locale setLocale(HttpServletRequest req)
Set the locale to the ThreadContext.


getBrowserLocale

public static Locale getBrowserLocale(HttpServletRequest req)
Read the locale from the browser.


getContextPath

public static String getContextPath()
Returns the context path of this application.


addModificationInfo

public static void addModificationInfo(HttpServletRequest req,
                                       HttpServletResponse resp,
                                       long lastModified,
                                       Locale locale)
adds some header fields to the response so we can determine modification on the next request
adds an ETag and a Last-Modified-Header

Parameters:
req - request
resp - response
lastModified - last modification timestamp
locale - the current locale

isModifiedSince

public static boolean isModifiedSince(HttpServletRequest req,
                                      HttpServletResponse resp,
                                      long lastModified,
                                      Locale l)
returns true if the requested resource has been modified since the last request
the following methods are used:
  1. check the ETag-header
  2. check the if-modified-since - header

Parameters:
req - request
resp - response
lastModified - last modification timestamp
l - the current locale
Returns:
true if the resource has been modified since the the last request, false otherwise

setExpiresImmediatelyForGuest

public static void setExpiresImmediatelyForGuest(HttpServletRequest req,
                                                 HttpServletResponse res)
if no user is currently logged in, it's required, that some resources are not cached, so the user gets the new files as soon he loggs in

Parameters:
req -
res -


@enterprise 8.0.10078 Copyright © 2001-2011 Groiss Informatics GmbH. All Rights Reserved.