|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.pmdesigns.jvc.JVCRequestContext
public final class JVCRequestContext
This class contains state information for processing an http request. It wraps the standard HttpServletRequest, HttpServletResponse and HttpServlet objects and provides convenience methods for accessing them.
It also provides access to the 'flash' which is a Map for storing temporary key/value strings. The scope of the flash is the current request or the following request in the case of a redirect response.
It also contains some convenience methods for forming links and absolute paths.
Field Summary | |
---|---|
java.lang.String |
action
The action is the last part of the servlet path (before any query arguments) |
java.lang.String |
controller
The controller is the servlet path up to the action. |
java.util.Map<java.lang.String,java.lang.String> |
flash
The 'flash' map for holding temporary key/value strings. |
javax.servlet.http.HttpServletRequest |
request
The actual HttpServletRequest object |
javax.servlet.http.HttpServletResponse |
response
The actual HttpServletResponse object |
javax.servlet.http.HttpServlet |
servlet
The HttpServlet object (actually this is a JVCDispatcher) |
Method Summary | |
---|---|
java.lang.String |
absPath(java.lang.String path)
Convenience method to prepend the context path onto a servlet path |
static java.lang.String |
getCachedBlock(java.lang.String key)
Internal method used to retrieve a cached block |
java.lang.String |
getContextPath()
Convenience method. |
javax.servlet.http.Cookie |
getCookie(java.lang.String name)
Convenience method to get cookie by name |
java.lang.String[] |
getCookieNames()
Convenience method to get all the cookie names. |
java.lang.String |
getFlash(java.lang.String key)
Convenience method to retrieve a value from the flash |
java.lang.String |
getMethod()
Convenience method |
java.lang.String |
getParam(java.lang.String name)
Convenience method |
java.util.Map<java.lang.String,java.lang.String> |
getParamMap(java.lang.String name)
Convenience method which gathers all parameters of the form ' |
java.lang.String[] |
getParamNames()
Convenience method to get all the parameter names. |
java.lang.String[] |
getParamValues(java.lang.String name)
Convenience method. |
java.lang.String |
getQueryString()
Convenience method. |
java.lang.String |
getScheme()
Convenience method |
java.lang.String |
getServerName()
Convenience method |
int |
getServerPort()
Convenience method |
java.lang.String |
getServletPath()
Convenience method. |
java.lang.Object |
getSessionAttr(java.lang.String name)
Convenience method |
java.lang.String[] |
getSessionAttrNames()
Convenience method |
boolean |
isGet()
Convenience method to check if this request is a GET |
boolean |
isPost()
Convenience method to check if this request is a POST |
boolean |
isSecure()
Convenience method |
java.lang.String |
makeLink(java.lang.String anchor,
java.lang.String path)
Convenience method to create an html anchor link tag |
java.lang.String |
makeLink(java.lang.String anchor,
java.lang.String path,
java.lang.String options)
Convenience method to create an html anchor link tag |
void |
nonStandardResponse(int httpCode,
java.lang.String arg)
Cause a non-standard response (ie. redirect) to be returned. |
void |
redirect(java.lang.String path)
Cause a redirect response to be returned |
void |
removeSessionAttr(java.lang.String name)
Convenience method |
static void |
setCachedBlock(java.lang.String key,
java.lang.String val)
Internal method used to store a cached block |
void |
setCookie(javax.servlet.http.Cookie cookie)
Convenience method |
void |
setFlash(java.lang.String key,
java.lang.String val)
Convenience method to add a value to the flash |
void |
setSessionAttr(java.lang.String name,
java.lang.Object value)
Convenience method |
java.lang.String |
toString()
For debugging |
java.lang.String |
toString(java.lang.String sep)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final javax.servlet.http.HttpServletRequest request
public final javax.servlet.http.HttpServletResponse response
public final javax.servlet.http.HttpServlet servlet
public final java.lang.String controller
public final java.lang.String action
public final java.util.Map<java.lang.String,java.lang.String> flash
Method Detail |
---|
public boolean isSecure()
public java.lang.String getScheme()
public java.lang.String getMethod()
public java.lang.String getServerName()
public int getServerPort()
public java.lang.String getContextPath()
getServletPath()
,
getQueryString()
public java.lang.String getServletPath()
getContextPath()
,
getQueryString()
public java.lang.String getQueryString()
getContextPath()
,
getServletPath()
public java.lang.String getParam(java.lang.String name)
name
- which parameter to get
getParamMap(java.lang.String)
,
getParamValues(java.lang.String)
,
getParamNames()
public java.util.Map<java.lang.String,java.lang.String> getParamMap(java.lang.String name)
For example, if there are parameters: 'foo[bar1]' = 'baz1' 'foo[bar2]' = 'baz2' then getParamMap('foo') will returned the map: map['bar1'] = 'baz1' map['bar2'] = 'baz2'
name
- the prefix to be used to select parameters
getParam(java.lang.String)
,
getParamValues(java.lang.String)
,
getParamNames()
public java.lang.String[] getParamValues(java.lang.String name)
name
- the name of the parameter(s) to get
getParam(java.lang.String)
,
getParamMap(java.lang.String)
,
getParamNames()
public java.lang.String[] getParamNames()
getParam(java.lang.String)
,
getParamMap(java.lang.String)
,
getParamValues(java.lang.String)
public java.lang.Object getSessionAttr(java.lang.String name)
name
- the name of the attribute to retrieve
setSessionAttr(java.lang.String, java.lang.Object)
,
getSessionAttrNames()
public java.lang.String[] getSessionAttrNames()
getSessionAttr(java.lang.String)
,
setSessionAttr(java.lang.String, java.lang.Object)
,
removeSessionAttr(java.lang.String)
public void setSessionAttr(java.lang.String name, java.lang.Object value)
name
- the key to store the indicated valuevalue
- the object to be storedgetSessionAttr(java.lang.String)
,
removeSessionAttr(java.lang.String)
public void removeSessionAttr(java.lang.String name)
name
- the key ofsetSessionAttr(java.lang.String, java.lang.Object)
public javax.servlet.http.Cookie getCookie(java.lang.String name)
name
- the name of the cookie to get
setCookie(javax.servlet.http.Cookie)
,
getCookieNames()
public java.lang.String[] getCookieNames()
getCookie(java.lang.String)
,
setCookie(javax.servlet.http.Cookie)
public void setCookie(javax.servlet.http.Cookie cookie)
cookie
- the cookie to be added to the responsegetCookie(java.lang.String)
,
getCookieNames()
public void nonStandardResponse(int httpCode, java.lang.String arg)
httpCode
- the http response code to be returnedarg
- an argument or message to be returned (depends on response code)
NonStandardResponseException
- which is a subclass of RuntimeException.
If you call this method inside a try/catch block make sure you re-throw
the NonStandardResponseException.redirect(java.lang.String)
public void redirect(java.lang.String path)
path
- where to redirect to. If the path starts with a '/' character then
its assumed that this is an absolute link and the context path will be prepended to it
NonStandardResponseException
- which is a subclass of RuntimeException.
If you call this method inside a try/catch block make sure you re-throw
the NonStandardResponseException.nonStandardResponse(int, java.lang.String)
public java.lang.String absPath(java.lang.String path)
path
- a servlet path
public java.lang.String makeLink(java.lang.String anchor, java.lang.String path)
anchor
- the text in an anchor linkpath
- the anchor target, if the path starts with a '/' character then
its assumed that this is an absolute link and the context path will be prepended to itmakeLink(java.lang.String, java.lang.String)
,
absPath(java.lang.String)
public java.lang.String makeLink(java.lang.String anchor, java.lang.String path, java.lang.String options)
anchor
- the text in an anchor linkpath
- the anchor target, if the path starts with a '/' character then
its assumed that this is an absolute link and the context path will be prepended to itoptions
- extra html options to add to the anchor tagmakeLink(java.lang.String, java.lang.String)
,
absPath(java.lang.String)
public boolean isPost()
public boolean isGet()
public java.lang.String getFlash(java.lang.String key)
key
- the key to use to lookup a flash value
setFlash(java.lang.String, java.lang.String)
public void setFlash(java.lang.String key, java.lang.String val)
key
- the key to use to associate with the flash valueval
- the value to storegetFlash(java.lang.String)
public static java.lang.String getCachedBlock(java.lang.String key)
setCachedBlock(java.lang.String, java.lang.String)
public static void setCachedBlock(java.lang.String key, java.lang.String val)
getCachedBlock(java.lang.String)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String sep)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |