org.mmbase.servlet
Class JamesServlet

org.mmbase.servlet.JamesServlet
Direct Known Subclasses:
DoveServlet, performance, remoteXML, servdb, servflash, servjumpers, servscan, SimpleFormToMailServlet

public class JamesServlet

JamesServlet is a adaptor class its used to extend the basic Servlet to with the calls that where/are needed for 'James' servlets to provide services not found in suns Servlet API.

Version:
$Id: JamesServlet.java,v 1.33.2.1 2002/04/26 21:15:55 gerard Exp $
Author:
vpro

Constructor Summary
JamesServlet()
           
 
Method Summary
protected  void debug(java.lang.String msg)
          Debug method for logging.
 void decRefCount(org.mmbase.servlet.HttpServletRequest req)
          Decrease the reference count of the servlet
protected  void finalize()
          Notifies through logging that the servlet was removed.
 java.lang.String getAddress(org.mmbase.servlet.HttpServletRequest req)
          Extract hostname from request, get address and determine the proxies between it.
 java.lang.String getAuthorization(org.mmbase.servlet.HttpServletRequest req, org.mmbase.servlet.HttpServletResponse res)
          Try to get the default authorisation
 java.lang.String getAuthorization(org.mmbase.servlet.HttpServletRequest req, org.mmbase.servlet.HttpServletResponse res, java.lang.String server, java.lang.String level)
          Authenticates a user, If the user cannot be authenticated a login-popup will appear
 java.lang.String getCookie(org.mmbase.servlet.HttpServletRequest req, org.mmbase.servlet.HttpServletResponse res)
          This method retrieves the users' MMBase cookie name & value as 'name/value'.
protected  java.util.Hashtable getInitParameters()
          Retrieves all initialization parameters.
protected  java.lang.Object getModule(java.lang.String name)
          Retrieves a module.
 java.lang.String getParam(org.mmbase.servlet.HttpServletRequest req, int num)
          Get the parameter specified.
 java.util.Vector getParamVector(org.mmbase.servlet.HttpServletRequest req)
          Get the Vector containing all parameters
protected  java.util.Hashtable getProperties(java.lang.String name)
          Gets properties.
protected  java.lang.String getProperty(java.lang.String name, java.lang.String var)
          Gets a property out of the Environment.
static java.lang.String getRequestURL(org.mmbase.servlet.HttpServletRequest req)
          Return URI with QueryString appended
 void incRefCount(org.mmbase.servlet.HttpServletRequest req)
          Increase the reference count of the servlet (for debugging) and send running servlets to log once every 32 requests
 void init(org.mmbase.servlet.ServletConfig config)
          Initializes the servlet.
 

Constructor Detail

JamesServlet

public JamesServlet()
Method Detail

debug

protected void debug(java.lang.String msg)
Debug method for logging.

init

public void init(org.mmbase.servlet.ServletConfig config)
          throws org.mmbase.servlet.ServletException
Initializes the servlet.
Parameters:
config - the servlet configuration

getModule

protected final java.lang.Object getModule(java.lang.String name)
Retrieves a module. Creates the module if it hasn't been created yet (but does not initialize).
Parameters:
name - the name of the module to retrieve
Returns:
the Module, or null if it doesn't exist.

getInitParameters

protected final java.util.Hashtable getInitParameters()
Retrieves all initialization parameters. Note: overides the normal way to set init params in javax.

getProperties

protected final java.util.Hashtable getProperties(java.lang.String name)
Gets properties. If allowed.

getProperty

protected final java.lang.String getProperty(java.lang.String name,
                                             java.lang.String var)
Gets a property out of the Environment. If allowed

getAuthorization

public java.lang.String getAuthorization(org.mmbase.servlet.HttpServletRequest req,
                                         org.mmbase.servlet.HttpServletResponse res)
                                  throws java.lang.Exception
Try to get the default authorisation
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
Throws:
AuthorizationException - if the authorization fails.
NotLoggedInException - if the user hasn't logged in yet.

getAuthorization

public java.lang.String getAuthorization(org.mmbase.servlet.HttpServletRequest req,
                                         org.mmbase.servlet.HttpServletResponse res,
                                         java.lang.String server,
                                         java.lang.String level)
                                  throws AuthorizationException,
                                         NotLoggedInException
Authenticates a user, If the user cannot be authenticated a login-popup will appear
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
server - server-account. (for exameple 'film' or 'www')
level - loginlevel. (for example 'Basic' or 'MD5')
Throws:
AuthorizationException - if the authorization fails.
NotLoggedInException - if the user hasn't logged in yet.

getCookie

public java.lang.String getCookie(org.mmbase.servlet.HttpServletRequest req,
                                  org.mmbase.servlet.HttpServletResponse res)
This method retrieves the users' MMBase cookie name & value as 'name/value'. When the cookie can't be found, a new cookie will be added. When an old James cookie is found, the related MMBaseProperty 'value' field will be replaced with a new MMBase cookie name & value. The cookies domain will be implicit or explicit depending on the MMBASEROOT.properties value.
Parameters:
req - The HttpServletRequest.
res - The HttpServletResponse.
Returns:
A String with the users' MMBase cookie as 'name/value' or null when MMBase core module can't be found, or when the MMBase cookie is located but can't be retrieved from the cookies list.

getParam

public java.lang.String getParam(org.mmbase.servlet.HttpServletRequest req,
                                 int num)
Get the parameter specified.
Parameters:
req - The HttpServletRequest.

getParamVector

public java.util.Vector getParamVector(org.mmbase.servlet.HttpServletRequest req)
Get the Vector containing all parameters
Parameters:
req - The HttpServletRequest.

getRequestURL

public static java.lang.String getRequestURL(org.mmbase.servlet.HttpServletRequest req)
Return URI with QueryString appended
Parameters:
req - The HttpServletRequest.

decRefCount

public void decRefCount(org.mmbase.servlet.HttpServletRequest req)
Decrease the reference count of the servlet
Parameters:
req - The HttpServletRequest.

incRefCount

public void incRefCount(org.mmbase.servlet.HttpServletRequest req)
Increase the reference count of the servlet (for debugging) and send running servlets to log once every 32 requests
Parameters:
req - The HttpServletRequest.

finalize

protected void finalize()
Notifies through logging that the servlet was removed.

getAddress

public java.lang.String getAddress(org.mmbase.servlet.HttpServletRequest req)
Extract hostname from request, get address and determine the proxies between it. Needed to determine if user comes from an internal or external host, i.e. when using two streaming servers, one for external users and one for internal users.
Parameters:
req - The HTTP request, which contains hostname as ipaddress
Returns:
a string containing the proxy chain. in the format "clientproxy.clientside.com->dialin07.clientside.com"


MMBase 2002