com.interface21.web.bind
Class RequestUtils

java.lang.Object
  |
  +--com.interface21.web.bind.RequestUtils

public abstract class RequestUtils
extends java.lang.Object

Parameter extraction methods. This class supports an approach distinct from data binding, in which parameters of specific types are required. This is very useful for simple submissions.

Author:
Rod Johnson

Constructor Summary
RequestUtils()
           
 
Method Summary
static int getIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name, int defaultVal)
          Get an int parameter, with a fallback value.
static boolean getRequiredBooleanParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          True is true or yes (no case) or 1
static double getRequiredDoubleParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name)
           
static int getRequiredIntParameter(javax.servlet.http.HttpServletRequest request, java.lang.String name)
          Get an int parameter, throwing an exception if it isn't found or isn't a number
static void rejectRequestMethod(javax.servlet.http.HttpServletRequest request, java.lang.String method)
          Throw a ServletException if the given HTTP request method should be rejected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestUtils

public RequestUtils()
Method Detail

rejectRequestMethod

public static void rejectRequestMethod(javax.servlet.http.HttpServletRequest request,
                                       java.lang.String method)
                                throws javax.servlet.ServletException
Throw a ServletException if the given HTTP request method should be rejected
Parameters:
request - request to check
method - method, such as "GET", which should be rejected
method - to reject

getRequiredIntParameter

public static int getRequiredIntParameter(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String name)
                                   throws ServletRequestBindingException
Get an int parameter, throwing an exception if it isn't found or isn't a number
Throws:
ServletRequestBindingException: - subclass of ServletException, so it doesn't need to be caught

getIntParameter

public static int getIntParameter(javax.servlet.http.HttpServletRequest request,
                                  java.lang.String name,
                                  int defaultVal)
Get an int parameter, with a fallback value. Never throws an exception. Can pass a distinguished value to default to enable checks of whether it was supplied

getRequiredDoubleParameter

public static double getRequiredDoubleParameter(javax.servlet.http.HttpServletRequest request,
                                                java.lang.String name)
                                         throws ServletRequestBindingException

getRequiredBooleanParameter

public static boolean getRequiredBooleanParameter(javax.servlet.http.HttpServletRequest request,
                                                  java.lang.String name)
                                           throws ServletRequestBindingException
True is true or yes (no case) or 1


Rod Johnson and Spring contributors 2001-2003.