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, wait
getSessionAttribute, getSessionIdentifier, setSessionAttribute
public 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()
WebContext
getSessionStore
in interface WebContext
public void setSessionStore(SessionStore sessionStore)
WebContext
setSessionStore
in interface WebContext
sessionStore
- the session storepublic String getRequestParameter(String name)
WebContext
getRequestParameter
in interface WebContext
name
- name of the parameterpublic Object getRequestAttribute(String name)
WebContext
getRequestAttribute
in interface WebContext
name
- the name of the attributepublic void setRequestAttribute(String name, Object value)
WebContext
setRequestAttribute
in interface WebContext
name
- the name of the attributevalue
- the attributepublic Map<String,String[]> getRequestParameters()
WebContext
getRequestParameters
in interface WebContext
public String getRequestHeader(String name)
WebContext
getRequestHeader
in interface WebContext
name
- name of the headerpublic String getRequestMethod()
WebContext
getRequestMethod
in interface WebContext
public String getRemoteAddr()
WebContext
getRemoteAddr
in interface WebContext
public javax.servlet.http.HttpServletRequest getRequest()
public javax.servlet.http.HttpServletResponse getResponse()
public void writeResponseContent(String content)
WebContext
writeResponseContent
in interface WebContext
content
- content to write in responsepublic void setResponseStatus(int code)
WebContext
setResponseStatus
in interface WebContext
code
- status code to set for the responsepublic void setResponseHeader(String name, String value)
WebContext
setResponseHeader
in interface WebContext
name
- name of the headervalue
- value of the headerpublic void setResponseContentType(String content)
WebContext
setResponseContentType
in interface WebContext
content
- the content typepublic String getServerName()
WebContext
getServerName
in interface WebContext
public int getServerPort()
WebContext
getServerPort
in interface WebContext
public String getScheme()
WebContext
getScheme
in interface WebContext
public boolean isSecure()
WebContext
isSecure
in interface WebContext
public String getFullRequestURL()
WebContext
getFullRequestURL
in interface WebContext
public Collection<Cookie> getRequestCookies()
WebContext
getRequestCookies
in interface WebContext
public void addResponseCookie(Cookie cookie)
WebContext
addResponseCookie
in interface WebContext
cookie
- 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 WebContext
public String getRequestContent()
WebContext
getRequestContent
in interface WebContext
Copyright © 2017. All rights reserved.