public class J2EContext extends Object implements WebContext
| Constructor and Description |
|---|
J2EContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Build a J2E context from the current HTTP request and response.
|
J2EContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
SessionStore<J2EContext> sessionStore)
Build a J2E context from the current HTTP request and response.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResponseCookie(Cookie cookie)
Adds cookies to the response
|
String |
getFullRequestURL()
Return the full URL (with query string) the client used to request the server.
|
String |
getPath()
This is not implemented using
HttpServletRequest.getServletPath() or
HttpServletRequest.getPathInfo() because they both have strange behaviours
in different contexts (inside servlets, inside filters, various container implementation, etc) |
String |
getRemoteAddr()
Return the remote address.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Return the HTTP request.
|
Object |
getRequestAttribute(String name)
Return a request attribute.
|
String |
getRequestContent()
Gets content body of the original request.
|
Collection<Cookie> |
getRequestCookies()
Retrieves request cookies.
|
String |
getRequestHeader(String name)
Return a request header.
|
String |
getRequestMethod()
Return the request method.
|
String |
getRequestParameter(String name)
Return a request parameter.
|
Map<String,String[]> |
getRequestParameters()
Return all request parameters.
|
javax.servlet.http.HttpServletResponse |
getResponse()
Return the HTTP response.
|
String |
getScheme()
Return the scheme.
|
String |
getServerName()
Return the server name.
|
int |
getServerPort()
Return the server port.
|
SessionStore |
getSessionStore()
Get the session store.
|
boolean |
isSecure()
Return whether the request is secure.
|
void |
setRequestAttribute(String name,
Object value)
Save a request attribute.
|
void |
setResponseContentType(String content)
Sets the response content type.
|
void |
setResponseHeader(String name,
String value)
Add a header to the response.
|
void |
setResponseStatus(int code)
Set the response status.
|
void |
setSessionStore(SessionStore sessionStore)
Set the session store.
|
void |
writeResponseContent(String content)
Write some content in the response.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetSessionAttribute, getSessionIdentifier, setSessionAttributepublic J2EContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - the current requestresponse - the current responsepublic J2EContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
SessionStore<J2EContext> sessionStore)
request - the current requestresponse - the current responsesessionStore - the session store to usepublic SessionStore getSessionStore()
WebContextgetSessionStore in interface WebContextpublic void setSessionStore(SessionStore sessionStore)
WebContextsetSessionStore in interface WebContextsessionStore - the session storepublic String getRequestParameter(String name)
WebContextgetRequestParameter in interface WebContextname - name of the parameterpublic Object getRequestAttribute(String name)
WebContextgetRequestAttribute in interface WebContextname - the name of the attributepublic void setRequestAttribute(String name, Object value)
WebContextsetRequestAttribute in interface WebContextname - the name of the attributevalue - the attributepublic Map<String,String[]> getRequestParameters()
WebContextgetRequestParameters in interface WebContextpublic String getRequestHeader(String name)
WebContextgetRequestHeader in interface WebContextname - name of the headerpublic String getRequestMethod()
WebContextgetRequestMethod in interface WebContextpublic String getRemoteAddr()
WebContextgetRemoteAddr in interface WebContextpublic javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public void writeResponseContent(String content)
WebContextwriteResponseContent in interface WebContextcontent - content to write in responsepublic void setResponseStatus(int code)
WebContextsetResponseStatus in interface WebContextcode - status code to set for the responsepublic void setResponseHeader(String name, String value)
WebContextsetResponseHeader in interface WebContextname - name of the headervalue - value of the headerpublic void setResponseContentType(String content)
WebContextsetResponseContentType in interface WebContextcontent - the content typepublic String getServerName()
WebContextgetServerName in interface WebContextpublic int getServerPort()
WebContextgetServerPort in interface WebContextpublic String getScheme()
WebContextgetScheme in interface WebContextpublic boolean isSecure()
WebContextisSecure in interface WebContextpublic String getFullRequestURL()
WebContextgetFullRequestURL in interface WebContextpublic Collection<Cookie> getRequestCookies()
WebContextgetRequestCookies in interface WebContextpublic void addResponseCookie(Cookie cookie)
WebContextaddResponseCookie in interface WebContextcookie - a cookie to add to the responsepublic String getPath()
HttpServletRequest.getServletPath() or
HttpServletRequest.getPathInfo() because they both have strange behaviours
in different contexts (inside servlets, inside filters, various container implementation, etc)getPath in interface WebContextpublic String getRequestContent()
WebContextgetRequestContent in interface WebContextCopyright © 2017. All Rights Reserved.