com.eaio.j2ee.www.redirector
Class ReDirector

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.eaio.j2ee.www.redirector.ReDirector
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ReDirector
extends javax.servlet.http.HttpServlet

A servlet that redirects users based on data from an XML file. The file should have the following structure:

 <links>
  ...
  <link>
   <id>Link id</id>
   <href>Link URL</href>
  </link>
  ...
 <links>
 

Invoke the servlet with t as the parameter containing the key, for example:

servlet?t=RAH

The t parameter is not case sensitive.

The servlets needs an init parameter called "links" that specifies where to find the XML file containing the links.

CHANGES:

Author:
Johann Burkard
See Also:
Serialized Form

Field Summary
static java.lang.String PARAMETER_HOSTNAME
          The "hostname" parameter name.
static java.lang.String PARAMETER_INTERVAL
          The "interval" parameter name.
static java.lang.String PARAMETER_LINKS
          The "links" parameter name.
(package private) static long serialVersionUID
          The serial version UID.
 
Constructor Summary
ReDirector()
          No-argument constructor.
 
Method Summary
 void destroy()
          Clears pointers to fields.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Forwards requests to either external URLs or internal pages.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Forwards request to either external URLs or internal pages.
 long getLastModified(javax.servlet.http.HttpServletRequest request)
          Return the time the servlet reloaded the XML file last time.
 java.lang.String getServletInfo()
          Return servlet information.
 void init(javax.servlet.ServletConfig config)
          Initializes the servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, service, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
The serial version UID.

See Also:
Constant Field Values

PARAMETER_HOSTNAME

public static final java.lang.String PARAMETER_HOSTNAME
The "hostname" parameter name.

See Also:
Constant Field Values

PARAMETER_INTERVAL

public static final java.lang.String PARAMETER_INTERVAL
The "interval" parameter name.

See Also:
Constant Field Values

PARAMETER_LINKS

public static final java.lang.String PARAMETER_LINKS
The "links" parameter name.

See Also:
Constant Field Values
Constructor Detail

ReDirector

public ReDirector()
No-argument constructor. Does nothing.

Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the servlet.

Parameters:
config - the Servlet's configuration
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Clears pointers to fields.


doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Forwards requests to either external URLs or internal pages.

Parameters:
request - the request
response - the response
Throws:
javax.servlet.ServletException
java.io.IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Forwards request to either external URLs or internal pages.

Parameters:
request - the request
response - the response
Throws:
javax.servlet.ServletException
java.io.IOException

getServletInfo

public java.lang.String getServletInfo()
Return servlet information.

Returns:
String

getLastModified

public long getLastModified(javax.servlet.http.HttpServletRequest request)
Return the time the servlet reloaded the XML file last time.

Returns:
the timestamp