|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.util.http.RequestHelper
public abstract class RequestHelper
Static helper function for extracting special information from requests.
Constructor Summary | |
---|---|
RequestHelper()
|
Method Summary | |
---|---|
static Boolean |
getBooleanParameter(javax.servlet.http.HttpServletRequest req,
String key)
Get the value of the servlet parameter key and parse it
using Boolean.parseBoolean(String) if a value for this servlet parameter
has been found. |
static Double |
getDoubleParameter(javax.servlet.http.HttpServletRequest req,
String key)
Get the value of the servlet parameter key and parse it
using Double.parseDouble(String) if a value for this servlet parameter
has been found. |
static Integer |
getIntegerParameter(javax.servlet.http.HttpServletRequest req,
String key)
Get the value of the servlet parameter key and parse it
using Integer.parseInt(String) if a value for this servlet parameter
has been found. |
static Long |
getLongParameter(javax.servlet.http.HttpServletRequest req,
String key)
Get the value of the servlet parameter key and parse it
using Long.parseLong(String) if a value for this servlet parameter
has been found. |
static String |
getRealRemoteIP(javax.servlet.http.HttpServletRequest request)
Get the remote IP address of the client taking the X-Forwarded-for header into account. |
static String |
getResolvedPath(javax.servlet.http.HttpServletRequest req)
Get the server-side path which may have been resolved by a delegating servlet. |
static void |
setResolvedPath(javax.servlet.http.HttpServletRequest req,
String resolvedPath)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RequestHelper()
Method Detail |
---|
public static void setResolvedPath(javax.servlet.http.HttpServletRequest req, String resolvedPath)
req
- The request to inform about path resolution.resolvedPath
- The resolved server-side path to be propagted to a delegate
servlet.public static String getResolvedPath(javax.servlet.http.HttpServletRequest req)
req
- The request to query.
RESOLVED_PATH_ATTR
attribute
or The result of HttpServletRequest.getPathInfo()
, if
no such attribute is present.public static String getRealRemoteIP(javax.servlet.http.HttpServletRequest request)
Get the remote IP address of the client taking the
X-Forwarded-for
header into account.
If no X-Forwarded-for
header is present,
the value of ServletRequest.getRemoteAddr()
is returned.
If a X-Forwarded-for
header is present,
the leftmost value in the comma-separated list of
X-Forwarded-for
-addresses is returned.
The rationale for returning the leftmost address is, that
this is the original address of the client.
request
- A HTTP servlet request.
public static Double getDoubleParameter(javax.servlet.http.HttpServletRequest req, String key) throws NumberFormatException
Get the value of the servlet parameter key
and parse it
using Double.parseDouble(String)
if a value for this servlet parameter
has been found.
Warning:
For POST requests with a Content-Type application/x-www-form-urlencoded
this method triggers a parsing of the all posted query parameters.
To avoid this, use UrlHelper.parseQuery(String)
together with
UrlHelper.getDoubleParameter(java.util.Map, String)
.
req
- The HTTP servlet request to query.key
- The key of the double parameter to parse.
null
if no request parameter with name key
is given.
NumberFormatException
- If the value of the servlet parameter is
not a double value as per Double.parseDouble(String)
.public static Long getLongParameter(javax.servlet.http.HttpServletRequest req, String key) throws NumberFormatException
Get the value of the servlet parameter key
and parse it
using Long.parseLong(String)
if a value for this servlet parameter
has been found.
Warning:
For POST requests with a Content-Type application/x-www-form-urlencoded
this method triggers a parsing of the all posted query parameters.
To avoid this, use UrlHelper.parseQuery(String)
together with
UrlHelper.getLongParameter(java.util.Map, String)
.
req
- The HTTP servlet request to query.key
- The key of the long parameter to parse.
null
if no request parameter with name key
is given.
NumberFormatException
- If the value of the servlet parameter is
not a long value as per Long.parseLong(String)
.public static Integer getIntegerParameter(javax.servlet.http.HttpServletRequest req, String key) throws NumberFormatException
Get the value of the servlet parameter key
and parse it
using Integer.parseInt(String)
if a value for this servlet parameter
has been found.
Warning:
For POST requests with a Content-Type application/x-www-form-urlencoded
this method triggers a parsing of the all posted query parameters.
To avoid this, use UrlHelper.parseQuery(String)
together with
UrlHelper.getIntegerParameter(java.util.Map, String)
.
req
- The HTTP servlet request to query.key
- The key of the integer parameter to parse.
null
if no request parameter with name key
is given.
NumberFormatException
- If the value of the servlet parameter is
not an integer value as per Integer.parseInt(String)
.public static Boolean getBooleanParameter(javax.servlet.http.HttpServletRequest req, String key)
Get the value of the servlet parameter key
and parse it
using Boolean.parseBoolean(String)
if a value for this servlet parameter
has been found.
Warning:
For POST requests with a Content-Type application/x-www-form-urlencoded
this method triggers a parsing of the all posted query parameters.
To avoid this, use UrlHelper.parseQuery(String)
together with
UrlHelper.getBooleanParameter(java.util.Map, String)
.
req
- The HTTP servlet request to query.key
- The key of the boolean parameter to parse.
null
if no request parameter with name key
is given.
NumberFormatException
- If the value of the servlet parameter is
not an integer value as per Boolean.parseBoolean(String)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |