|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ServletRequest
ServletRequest encapsulates client request data. See HttpServletRequest for HTTP-specific information.
Requests have user-defined attributes. Servlets can communicate to included or forwarded pages using the request attributes. For example, a servlet may calculate results and place them in the request attributes. It may then forward the call to a JSP template to format the result.
Form parameters are retrieved using getParameter
| Method Summary | |
|---|---|
void |
complete()
Complete the request |
java.lang.Object |
getAttribute(java.lang.String name)
Returns an attribute value. |
java.util.Enumeration |
getAttributeNames()
Enumerates all attribute names in the request. |
java.lang.String |
getCharacterEncoding()
Returns the character encoding of the POSTed data. |
int |
getContentLength()
Returns the content length of the data. |
java.lang.String |
getContentType()
Returns the request's mime-type. |
ServletInputStream |
getInputStream()
Returns an InputStream to retrieve POST data from the request. |
java.lang.String |
getLocalAddr()
This call returns the ip of the host actually used to connect to the Resin server, which means that if ipchains, load balancing, or proxying is involved this call does not return the correct host for forming urls. |
java.util.Locale |
getLocale()
Returns the request's preferred locale, based on the Accept-Language header. |
java.util.Enumeration |
getLocales()
Returns an enumeration of all locales acceptable by the client. |
java.lang.String |
getLocalName()
Returns the IP address of the local host, i.e. |
int |
getLocalPort()
Returns the port of the local host. |
java.lang.String |
getParameter(java.lang.String name)
Returns a form parameter. |
java.util.Map |
getParameterMap()
Returns a Map of the form parameters. |
java.util.Enumeration |
getParameterNames()
Returns an enumeration of all form parameter names. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns all values of a form parameter. |
java.lang.String |
getProtocol()
Returns the prococol, e.g. |
java.io.BufferedReader |
getReader()
Returns a reader to read POSTed data. |
java.lang.String |
getRealPath(java.lang.String uri)
Returns the path of the URI. |
java.lang.String |
getRemoteAddr()
Returns the IP address of the remote host, i.e. |
java.lang.String |
getRemoteHost()
Returns the DNS hostname of the remote host, i.e. |
int |
getRemotePort()
Returns the port of the remote host, i.e. |
RequestDispatcher |
getRequestDispatcher(java.lang.String uri)
Returns a request dispatcher for later inclusion or forwarding. |
java.lang.String |
getScheme()
Returns the request scheme, e.g. |
java.lang.String |
getServerName()
Returns the server name handling the request. |
int |
getServerPort()
Returns the server port used by the client, e.g. |
ServletContext |
getServletContext()
Returns the servlet context for the request |
ServletResponse |
getServletResponse()
Returns the servlet response for the request |
boolean |
isInitial()
Returns true for the initial dispatch |
boolean |
isResumed()
Returns true if the servlet is resumed |
boolean |
isSecure()
Returns true if the connection is secure, e.g. |
boolean |
isSuspended()
Returns true if the servlet is suspended |
boolean |
isTimeout()
Returns true if the servlet timed out |
void |
removeAttribute(java.lang.String name)
Removes the given attribute. |
void |
resume()
Resume the request |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Sets an attribute value. |
void |
setCharacterEncoding(java.lang.String encoding)
Overrides the character encoding specified in the request. |
void |
suspend()
Suspend the request |
void |
suspend(long timeout)
Suspend the request |
| Method Detail |
|---|
java.lang.String getProtocol()
java.lang.String getScheme()
java.lang.String getServerName()
int getServerPort()
isSecure() is provided for that purpose.
java.lang.String getRemoteAddr()
java.lang.String getRemoteHost()
int getRemotePort()
java.lang.String getLocalAddr()
java.lang.String getLocalName()
int getLocalPort()
isSecure() is provided for that purpose.
void setCharacterEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
setCharacterEncoding must be called before calling
getReader or reading any parameters.
java.io.UnsupportedEncodingExceptionjava.lang.String getParameter(java.lang.String name)
getParameter returns the first.
For example, calling getParameter("a") with the
the query string a=1&a=2 will return "1".
name - the form parameter to return
java.lang.String[] getParameterValues(java.lang.String name)
For example, calling getParameterValues("a")
with the the query string a=1&a=2 will
return ["1", "2"].
name - the form parameter to return
java.util.Enumeration getParameterNames()
Enumeration e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
out.println(name + ": " + request.getParameter(name));
}
java.util.Map getParameterMap()
getParameterNames
and the values are String arrays as returned by
getParameterValues.
ServletInputStream getInputStream()
throws java.io.IOException
java.io.IOException
java.io.BufferedReader getReader()
throws java.io.IOException,
java.lang.IllegalStateException
getCharacterEncoding()
java.io.IOException
java.lang.IllegalStateExceptionjava.lang.String getCharacterEncoding()
int getContentLength()
The upshot is, rely on the input stream to end when the data completes.
java.lang.String getContentType()
java.util.Locale getLocale()
java.util.Enumeration getLocales()
boolean isSecure()
java.lang.Object getAttribute(java.lang.String name)
name - the attribute name
void setAttribute(java.lang.String name,
java.lang.Object o)
name - the attribute nameo - the attribute valuejava.util.Enumeration getAttributeNames()
void removeAttribute(java.lang.String name)
name - the attribute nameRequestDispatcher getRequestDispatcher(java.lang.String uri)
uri
is relative to the request URI. Absolute URIs are relative to
the application prefix (getContextPath()).
If getRequestURI() is /myapp/dir/test.jsp and the
uri is "inc.jsp", the resulting page is
/myapp/dir/inc.jsp.
RequestDispatcher disp;
disp = getRequestDispatcher("inc.jsp?a=b");
disp.include(request, response);
uri - path relative to getRequestURI()
(including query string) for the included file.
java.lang.String getRealPath(java.lang.String uri)
ServletContext getServletContext()
ServletResponse getServletResponse()
void suspend(long timeout)
void suspend()
void resume()
void complete()
boolean isSuspended()
boolean isResumed()
boolean isTimeout()
boolean isInitial()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||