org.oddjob.webapp.servlets
Class InitParam

java.lang.Object
  extended by org.oddjob.webapp.servlets.InitParam

public class InitParam
extends Object

Utility class that allows initialisation parameters to be specified either in the Servlet context (the web.xml) or in the container configuration.

The advantage of specifying parameters in the Servlet context is they can be specified on a machine by machine bases and be independent of the deployed web application archive.

This utility will first look for a container parameter before looking for a web.xml version.

Author:
rob

Constructor Summary
InitParam(ServletConfig config)
          Constructor.
 
Method Summary
 String getInitParam(String parameterName)
          Get the initialisation parameter, or null if it's not specified.
 String getInitParam(String parameterName, String theDefault)
          Get the initialisation parameter with a default if it's not specified.
 String getRequiredInitParam(String parameterName)
          Get a parameter that must be specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InitParam

public InitParam(ServletConfig config)
Constructor.

Parameters:
config - The Servlet container configuration
Method Detail

getInitParam

public String getInitParam(String parameterName)
Get the initialisation parameter, or null if it's not specified.

Parameters:
parameterName - The parameter.
Returns:
The value or null if none is found.

getInitParam

public String getInitParam(String parameterName,
                           String theDefault)
Get the initialisation parameter with a default if it's not specified.

Parameters:
parameterName - The parameter.
theDefault - The default value. May be null.
Returns:
The value, or the default value if no value is found.

getRequiredInitParam

public String getRequiredInitParam(String parameterName)
                            throws ServletException
Get a parameter that must be specified.

Parameters:
parameterName - The parameter.
Returns:
A value. Never null.
Throws:
ServletException - If the parameter doesn't exist.