Package org.bedework.util.servlet
Class ReqUtil
- java.lang.Object
-
- org.bedework.util.servlet.ReqUtil
-
- All Implemented Interfaces:
Serializable
public class ReqUtil extends Object implements Serializable
Class to handle the incoming request.- Author:
- Mike Douglass
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReqUtil(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleangetBooleanReqPar(String name)Get a boolean valued request parameter.booleangetBooleanReqPar(String name, boolean defVal)Get a boolean valued request parameter giving a default value.booleangetErrFlag()IntegergetIntReqPar(String name)Get an Integer request parameter or null.intgetIntReqPar(String name, int defaultVal)Get an integer valued request parameter.Collection<Locale>getLocales()If there is no Accept-Language header returns null, otherwise returns a collection of Locales ordered with preferred first.LonggetLongReqPar(String name)Get a Long request parameter or null.longgetLongReqPar(String name, long defaultVal)Get an long valued request parameter.StringgetRemoteAddr()StringgetRemoteHost()intgetRemotePort()StringgetReqPar(String name)Get a request parameter stripped of white space.StringgetReqPar(String name, String def)Get a request parameter stripped of white space.List<String>getReqPars(String name)Get a multi-valued request parameter stripped of white space.javax.servlet.http.HttpServletRequestgetRequest()ObjectgetRequestAttr(String attrName)Return the value of a named request attribute.javax.servlet.http.HttpServletResponsegetResponse()ObjectgetSessionAttr(String attrName)Return the value of a named session attribute.booleannotNull(String name)See if a request parameter is present and not null or emptybooleanpresent(String name)See if a request parameter is presentvoidremoveSessionAttr(String attrName)Remove a named session attribute.voidsetErrFlag(boolean val)voidsetRequestAttr(String attrName, Object val)Set the value of a named request attribute.voidsetSessionAttr(String attrName, Object val)Set the value of a named session attribute.
-
-
-
Method Detail
-
getRequest
public javax.servlet.http.HttpServletRequest getRequest()
- Returns:
- HttpServletRequest
-
getResponse
public javax.servlet.http.HttpServletResponse getResponse()
- Returns:
- HttpServletResponse
-
setErrFlag
public void setErrFlag(boolean val)
- Parameters:
val-
-
getErrFlag
public boolean getErrFlag()
- Returns:
- boolean
-
getReqPar
public String getReqPar(String name)
Get a request parameter stripped of white space. Return null for zero length.- Parameters:
name- name of parameter- Returns:
- String value
-
getReqPar
public String getReqPar(String name, String def)
Get a request parameter stripped of white space. Return default for null or zero length.- Parameters:
name- name of parameterdef- default value- Returns:
- String value
-
present
public boolean present(String name)
See if a request parameter is present- Parameters:
name- name of parameter- Returns:
- boolean true for present
-
notNull
public boolean notNull(String name) throws Throwable
See if a request parameter is present and not null or empty- Parameters:
name- name of parameter- Returns:
- boolean true for present and not null
- Throws:
Throwable
-
getReqPars
public List<String> getReqPars(String name) throws Throwable
Get a multi-valued request parameter stripped of white space. Return null for zero length.- Parameters:
name- name of parameter- Returns:
- List
or null - Throws:
Throwable
-
getIntReqPar
public Integer getIntReqPar(String name) throws Throwable
Get an Integer request parameter or null.- Parameters:
name- name of parameter- Returns:
- Integer value or null
- Throws:
Throwable
-
getIntReqPar
public int getIntReqPar(String name, int defaultVal) throws Throwable
Get an integer valued request parameter.- Parameters:
name- name of parameterdefaultVal-- Returns:
- int value
- Throws:
Throwable
-
getLongReqPar
public Long getLongReqPar(String name) throws Throwable
Get a Long request parameter or null.- Parameters:
name- name of parameter- Returns:
- Long value or null
- Throws:
Throwable
-
getLongReqPar
public long getLongReqPar(String name, long defaultVal) throws Throwable
Get an long valued request parameter.- Parameters:
name- name of parameterdefaultVal-- Returns:
- long value
- Throws:
Throwable
-
getBooleanReqPar
public Boolean getBooleanReqPar(String name) throws Throwable
Get a boolean valued request parameter.- Parameters:
name- name of parameter- Returns:
- Boolean value or null for absent parameter
- Throws:
Throwable
-
getBooleanReqPar
public boolean getBooleanReqPar(String name, boolean defVal) throws Throwable
Get a boolean valued request parameter giving a default value.- Parameters:
name- name of parameterdefVal- default value for absent parameter- Returns:
- boolean value
- Throws:
Throwable
-
setSessionAttr
public void setSessionAttr(String attrName, Object val)
Set the value of a named session attribute.- Parameters:
attrName- Name of the attributeval- Object
-
removeSessionAttr
public void removeSessionAttr(String attrName)
Remove a named session attribute.- Parameters:
attrName- Name of the attribute
-
getSessionAttr
public Object getSessionAttr(String attrName)
Return the value of a named session attribute.- Parameters:
attrName- Name of the attribute- Returns:
- Object Attribute value or null
-
setRequestAttr
public void setRequestAttr(String attrName, Object val)
Set the value of a named request attribute.- Parameters:
attrName- Name of the attributeval- Object
-
getRequestAttr
public Object getRequestAttr(String attrName)
Return the value of a named request attribute.- Parameters:
attrName- Name of the attribute- Returns:
- Object Attribute value or null
-
getRemoteAddr
public String getRemoteAddr()
- Returns:
- String remote address
-
getRemoteHost
public String getRemoteHost()
- Returns:
- String remote host
-
getRemotePort
public int getRemotePort()
- Returns:
- int remote port
-
getLocales
public Collection<Locale> getLocales()
If there is no Accept-Language header returns null, otherwise returns a collection of Locales ordered with preferred first.- Returns:
- Collection of locales or null
-
-