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 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()
Get the "servlet path" (in a J2E style).
|
String |
getRemoteAddr()
Return the remote address.
|
javax.servlet.http.HttpServletRequest |
getRequest()
Return the HTTP request.
|
Object |
getRequestAttribute(String name)
Return a request attribute.
|
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.
|
Object |
getSessionAttribute(String name)
Get an attribute from session.
|
Object |
getSessionIdentifier()
Gets the session id for this context.
|
SessionStore |
getSessionStore() |
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 |
setSessionAttribute(String name,
Object value)
Save an attribute in session.
|
void |
writeResponseContent(String content)
Write some content in the response.
|
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 sessionStore)
request
- the current requestresponse
- the current responsesessionStore
- the session store to usepublic 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 void setSessionAttribute(String name, Object value)
WebContext
setSessionAttribute
in interface WebContext
name
- name of the session attributevalue
- value of the session attributepublic Object getSessionAttribute(String name)
WebContext
getSessionAttribute
in interface WebContext
name
- name of the session attributepublic Object getSessionIdentifier()
WebContext
getSessionIdentifier
in interface WebContext
public 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 SessionStore getSessionStore()
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()
WebContext
getPath
in interface WebContext
Copyright © 2016. All rights reserved.