| net.jforum.context.RequestContext
All known Subclasses: net.jforum.context.web.WebRequestContext, net.jforum.context.standard.StandardRequestContext,
RequestContext | public interface RequestContext (Code) | | User: SergeMaslyukov Date: 20.08.2006 Time: 17:18:03 $Id: WebContextRequest.java,v 1.1
2006/08/20 15:30:29 sergemaslyukov Exp $
|
Method Summary | |
public void | addOrReplaceParameter(String name, Object value) Replace or add a parameter. | public void | addParameter(String name, Object value) Adds a new parameter to the request.
If there is already one parameter which name is equals to the
value of the "name" parameter, a set of values associated to that
name will be generated, thus requiring a call to getParameterValues()
to retrieve them all. | public String | getAction() Gets the action of the current request.
An Action is the parameter name which specifies what next action should be done by
the system. | public Object | getAttribute(String name) Returns the value of the named attribute as an Object , or null
if no attribute of the given name exists.
Attributes can be set two ways. | public String | getContextPath() Returns the portion of the request URI that indicates the context of the request. | public Cookie[] | getCookies() Returns an array containing all of the Cookie objects the client sent with
this request. | public String | getHeader(String name) Returns the value of the specified request header as a String . | public int | getIntParameter(String parameter) Gets an parameter that is a number. | public Locale | getLocale() Gets user browser's locale. | public String | getModule() Gets the module of the current request.
A Module is the parameter name which specifies what module the user is requesting. | public Object | getObjectParameter(String parameter) Gets some request parameter as Object . | public String | getParameter(String name) Returns the value of a request parameter as a String , or null
if the parameter does not exist. | public Enumeration | getParameterNames() Returns an Enumeration of String objects containing the names
of the parameters contained in this request. | public String[] | getParameterValues(String name) Returns an array of String objects containing all of the values the given
request parameter has, or null if the parameter does not exist. | public String | getQueryString() Returns the query string that is contained in the request URL after the path. | public String | getRemoteAddr() Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. | public String | getRemoteUser() Returns the login of the user making this request, if the user has been authenticated, or
null if the user has not been authenticated. | public String | getRequestURI() Returns the part of this request's URL from the protocol name up to the query string in the
first line of the HTTP request. | public String | getScheme() Returns the name of the scheme used to make this request, for example, http ,
https , or ftp . | public String | getServerName() Returns the host name of the server to which the request was sent. | public int | getServerPort() Returns the port number to which the request was sent. | public SessionContext | getSessionContext(boolean create) Returns the current HttpSession associated with this request or, if there is
no current session and create is true, returns a new session.
If create is false and the request has no valid
HttpSession , this method returns null .
To make sure the session is properly maintained, you must call this method before the
response is committed. | public SessionContext | getSessionContext() Returns the current session associated with this request, or if the request does not have a
session, creates one. | public void | removeAttribute(String name) Removes an attribute from this request. | public void | setAttribute(String name, Object o) Stores an attribute in this request. | public void | setCharacterEncoding(String env) Overrides the name of the character encoding used in the body of this request. |
addOrReplaceParameter | public void addOrReplaceParameter(String name, Object value)(Code) | | Replace or add a parameter. If it does not exist, it is added to the list,
otherwise the existing value will be replaced by the new value.
Parameters: name - Parameters: value - |
addParameter | public void addParameter(String name, Object value)(Code) | | Adds a new parameter to the request.
If there is already one parameter which name is equals to the
value of the "name" parameter, a set of values associated to that
name will be generated, thus requiring a call to getParameterValues()
to retrieve them all.
If you want to replace a possible existing value,
use
RequestContext.addOrReplaceParameter(String,Object) Parameters: name - Parameter name Parameters: value - Parameter value |
getAction | public String getAction()(Code) | | Gets the action of the current request.
An Action is the parameter name which specifies what next action should be done by
the system. It may be add or edit a post, editing the groups, whatever. In the URL, the
Action can the represented in two forms:
http://www.host.com/webapp/servletName?module=groups&action=list
or
http://www.host.com/webapp/servletName/groups/list
In both situations, the action's name is "list".
String representing the action name |
getAttribute | public Object getAttribute(String name)(Code) | | Returns the value of the named attribute as an Object , or null
if no attribute of the given name exists.
Attributes can be set two ways. The servlet container may set attributes to make available
custom information about a request. For example, for requests made using HTTPS, the attribute
javax.servlet.request.X509Certificate can be used to retrieve information on
the certificate of the client. Attributes can also be set programatically using
RequestContext.setAttribute . This allows information to be embedded into a request before a
javax.servlet.RequestDispatcher call.
Attribute names should follow the same conventions as package names. This specification
reserves names matching java.* , javax.* , and
sun.* .
Parameters: name - a String specifying the name of the attribute an Object containing the value of the attribute, or null if the attribute does not exist |
getContextPath | public String getContextPath()(Code) | | Returns the portion of the request URI that indicates the context of the request. The context
path always comes first in a request URI. The path starts with a "/" character but does not
end with a "/" character. For servlets in the default (root) context, this method returns "".
The container does not decode this string.
a String specifying the portion of the request URI that indicates thecontext of the request |
getCookies | public Cookie[] getCookies()(Code) | | Returns an array containing all of the Cookie objects the client sent with
this request. This method returns null if no cookies were sent.
an array of all the Cookies included with this request, ornull if the request has no cookies |
getHeader | public String getHeader(String name)(Code) | | Returns the value of the specified request header as a String . If the request
did not include a header of the specified name, this method returns null . If
there are multiple headers with the same name, this method returns the first head in the
request. The header name is case insensitive. You can use this method with any request
header.
Parameters: name - a String specifying the header name a String containing the value of the requested header, ornull if the request does not have a header of that name |
getIntParameter | public int getIntParameter(String parameter)(Code) | | Gets an parameter that is a number. A call to Integer#parseInt(String) is made
to do the conversion
Parameters: parameter - The parameter name to get the value int |
getLocale | public Locale getLocale()(Code) | | Gets user browser's locale. This method may be used during first installation to
automatically switch to corresponding language I18N resource.
Locale |
getModule | public String getModule()(Code) | | Gets the module of the current request.
A Module is the parameter name which specifies what module the user is requesting. It
may be the group administration, the topics or anything else configured module. In the URL,
the Module can the represented in two forms:
http://www.host.com/webapp/servletName?module=groups&action=list
or
http://www.host.com/webapp/servletName/groups/list
In both situations, the module's name is "groups".
String representing the module name |
getObjectParameter | public Object getObjectParameter(String parameter)(Code) | | Gets some request parameter as Object . This method may be used when you have
to get some value of a multipart/form-data request, like a image of file.
Parameters: parameter - String Object |
getParameter | public String getParameter(String name)(Code) | | Returns the value of a request parameter as a String , or null
if the parameter does not exist. Request parameters are extra information sent with the
request. For HTTP servlets, parameters are contained in the query string or posted form data.
You should only use this method when you are sure the parameter has only one value. If the
parameter might have more than one value, use
RequestContext.getParameterValues .
If you use this method with a multivalued parameter, the value returned is equal to the first
value in the array returned by getParameterValues .
If the parameter data was sent in the request body, such as occurs with an HTTP POST request,
then reading the body directly via
RequestContext.getInputStream or
RequestContext.getReader can
interfere with the execution of this method.
Parameters: name - a String specifying the name of the parameter a String representing the single value of the parameter See Also: RequestContext.getParameterValues |
getParameterNames | public Enumeration getParameterNames()(Code) | | Returns an Enumeration of String objects containing the names
of the parameters contained in this request. If the request has no parameters, the method
returns an empty Enumeration .
an Enumeration of String objects, eachString containing the name of a request parameter; or an emptyEnumeration if the request has no parameters |
getParameterValues | public String[] getParameterValues(String name)(Code) | | Returns an array of String objects containing all of the values the given
request parameter has, or null if the parameter does not exist.
If the parameter has a single value, the array has a length of 1.
Parameters: name - a String containing the name of the parameter whose value is requested an array of String objects containing the parameter's values See Also: RequestContext.getParameter |
getQueryString | public String getQueryString()(Code) | | Returns the query string that is contained in the request URL after the path. This method
returns null if the URL does not have a query string. Same as the value of the
CGI variable QUERY_STRING.
a String containing the query string or null if the URLcontains no query string. The value is not decoded by the container. |
getRemoteAddr | public String getRemoteAddr()(Code) | | Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
For HTTP servlets, same as the value of the CGI variable REMOTE_ADDR .
a String containing the IP address of the client that sent the request |
getRemoteUser | public String getRemoteUser()(Code) | | Returns the login of the user making this request, if the user has been authenticated, or
null if the user has not been authenticated. Whether the user name is sent
with each subsequent request depends on the browser and type of authentication. Same as the
value of the CGI variable REMOTE_USER.
a String specifying the login of the user making this request, ornull if the user login is not known |
getRequestURI | public String getRequestURI()(Code) | | Returns the part of this request's URL from the protocol name up to the query string in the
first line of the HTTP request. The web container does not decode this String. For example:
First line of HTTP request |
Returned Value |
POST /some/path.html HTTP/1.1
|
| /some/path.html
|
GET http://foo.bar/a.html HTTP/1.0
|
| /a.html
|
HEAD /xyz?a=b HTTP/1.1
|
| /xyz |
To reconstruct an URL with a scheme and host, use
javax.servlet.http.HttpUtils.getRequestURL .
a String containing the part of the URL from the protocol name up tothe query string See Also: javax.servlet.http.HttpUtils.getRequestURL |
getScheme | public String getScheme()(Code) | | Returns the name of the scheme used to make this request, for example, http ,
https , or ftp . Different schemes have different rules for
constructing URLs, as noted in RFC 1738.
a String containing the name of the scheme used to make this request |
getServerName | public String getServerName()(Code) | | Returns the host name of the server to which the request was sent. It is the value of the
part before ":" in the Host header value, if any, or the resolved server name,
or the server IP address.
a String containing the name of the server |
getServerPort | public int getServerPort()(Code) | | Returns the port number to which the request was sent. It is the value of the part after ":"
in the Host header value, if any, or the server port where the client
connection was accepted on.
an integer specifying the port number |
getSessionContext | public SessionContext getSessionContext(boolean create)(Code) | | Returns the current HttpSession associated with this request or, if there is
no current session and create is true, returns a new session.
If create is false and the request has no valid
HttpSession , this method returns null .
To make sure the session is properly maintained, you must call this method before the
response is committed. If the container is using cookies to maintain session integrity and is
asked to create a new session when the response is committed, an IllegalStateException is
thrown.
Parameters: create - true to create a new session for this request if necessary;false to return null if there's no current session the HttpSession associated with this request or null ifcreate is false and the request has no valid session See Also: RequestContext.getSessionContext() |
removeAttribute | public void removeAttribute(String name)(Code) | | Removes an attribute from this request. This method is not generally needed as attributes
only persist as long as the request is being handled.
Attribute names should follow the same conventions as package names. Names beginning with
java.* , javax.* , and com.sun.* , are reserved
for use by Sun Microsystems.
Parameters: name - a String specifying the name of the attribute to remove |
setAttribute | public void setAttribute(String name, Object o)(Code) | | Stores an attribute in this request. Attributes are reset between requests. This method is
most often used in conjunction with
javax.servlet.RequestDispatcher .
Attribute names should follow the same conventions as package names. Names beginning with
java.* , javax.* , and com.sun.* , are reserved
for use by Sun Microsystems.
If the object passed in is null, the effect is the same as calling
RequestContext.removeAttribute .
It is warned that when the request is dispatched from the servlet resides in a different web
application by RequestDispatcher , the object set by this method may not be
correctly retrieved in the caller servlet.
Parameters: name - a String specifying the name of the attribute Parameters: o - the Object to be stored |
setCharacterEncoding | public void setCharacterEncoding(String env) throws UnsupportedEncodingException(Code) | | Overrides the name of the character encoding used in the body of this request. This method
must be called prior to reading request parameters or reading input using getReader().
Parameters: env - a String containing the name of the character encoding. throws: java.io.UnsupportedEncodingException - if this is not a valid encoding |
|
|