public class Request extends Object implements javax.servlet.http.HttpServletRequest
Implements HttpServletRequest from the javax.servlet.http package.
The standard interface of mostly getters, is extended with setters so that the request is mutable by the handlers that it is passed to. This allows the request object to be as lightweight as possible and not actually implement any significant behavior. For example
getContextPath() method will return null, until the request has been passed to a ContextHandler which matches the
getPathInfo() with a context path and calls setContextPath(String) as a result.SessionHandler which checks for session cookies and enables the ability to create new sessions.getServletPath() method will return null until the request has been passed to a org.eclipse.jetty.servlet.ServletHandler
and the pathInfo matched against the servlet URL patterns and setServletPath(String) called as a result.AbstractHttpConnection accepted by the server and recycled for each HTTP request received via that connection.
An effort is made to avoid reparsing headers and cookies that are likely to be the same for requests from the same connection.
The form content that a request can process is limited to protect from Denial of Service attacks. The size in bytes is limited by
ContextHandler.getMaxFormContentSize() or if there is no context then the "org.eclipse.jetty.server.Request.maxFormContentSize" Server
attribute. The number of parameters keys is limited by ContextHandler.getMaxFormKeys() or if there is no context then the
"org.eclipse.jetty.server.Request.maxFormKeys" Server attribute.
| Modifier and Type | Class and Description |
|---|---|
static class |
Request.MultiPartCleanerListener |
| Modifier and Type | Field and Description |
|---|---|
static String |
__MULTIPART_CONFIG_ELEMENT |
static String |
__MULTIPART_CONTEXT |
static String |
__MULTIPART_INPUT_STREAM |
protected AsyncContinuation |
_async |
protected AbstractHttpConnection |
_connection |
| Constructor and Description |
|---|
Request() |
Request(AbstractHttpConnection connection) |
public static final String __MULTIPART_CONFIG_ELEMENT
public static final String __MULTIPART_INPUT_STREAM
public static final String __MULTIPART_CONTEXT
protected final AsyncContinuation _async
protected AbstractHttpConnection _connection
public Request()
public Request(AbstractHttpConnection connection)
public static Request getRequest(javax.servlet.http.HttpServletRequest request)
public void addEventListener(EventListener listener)
public void extractParameters()
public javax.servlet.AsyncContext getAsyncContext()
getAsyncContext in interface javax.servlet.ServletRequestpublic AsyncContinuation getAsyncContinuation()
public Object getAttribute(String name)
getAttribute in interface javax.servlet.ServletRequestpublic Enumeration getAttributeNames()
getAttributeNames in interface javax.servlet.ServletRequestpublic Attributes getAttributes()
public Authentication getAuthentication()
public String getAuthType()
getAuthType in interface javax.servlet.http.HttpServletRequestpublic String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletRequestpublic AbstractHttpConnection getConnection()
public int getContentLength()
getContentLength in interface javax.servlet.ServletRequestpublic long getContentRead()
public String getContentType()
getContentType in interface javax.servlet.ServletRequestpublic ContextHandler.Context getContext()
context used for this request, or null if setContext(org.eclipse.jetty.server.handler.ContextHandler.Context) has not yet been called.public String getContextPath()
getContextPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.Cookie[] getCookies()
getCookies in interface javax.servlet.http.HttpServletRequestpublic long getDateHeader(String name)
getDateHeader in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.DispatcherType getDispatcherType()
getDispatcherType in interface javax.servlet.ServletRequestpublic String getHeader(String name)
getHeader in interface javax.servlet.http.HttpServletRequestpublic Enumeration getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletRequestpublic Enumeration getHeaders(String name)
getHeaders in interface javax.servlet.http.HttpServletRequestpublic int getInputState()
public javax.servlet.ServletInputStream getInputStream()
throws IOException
getInputStream in interface javax.servlet.ServletRequestIOExceptionpublic int getIntHeader(String name)
getIntHeader in interface javax.servlet.http.HttpServletRequestpublic String getLocalAddr()
getLocalAddr in interface javax.servlet.ServletRequestpublic Locale getLocale()
getLocale in interface javax.servlet.ServletRequestpublic Enumeration getLocales()
getLocales in interface javax.servlet.ServletRequestpublic String getLocalName()
getLocalName in interface javax.servlet.ServletRequestpublic int getLocalPort()
getLocalPort in interface javax.servlet.ServletRequestpublic String getMethod()
getMethod in interface javax.servlet.http.HttpServletRequestpublic String getParameter(String name)
getParameter in interface javax.servlet.ServletRequestpublic Map getParameterMap()
getParameterMap in interface javax.servlet.ServletRequestpublic Enumeration getParameterNames()
getParameterNames in interface javax.servlet.ServletRequestpublic String[] getParameterValues(String name)
getParameterValues in interface javax.servlet.ServletRequestpublic String getPathInfo()
getPathInfo in interface javax.servlet.http.HttpServletRequestpublic String getPathTranslated()
getPathTranslated in interface javax.servlet.http.HttpServletRequestpublic String getProtocol()
getProtocol in interface javax.servlet.ServletRequestpublic String getQueryEncoding()
public String getQueryString()
getQueryString in interface javax.servlet.http.HttpServletRequestpublic BufferedReader getReader() throws IOException
getReader in interface javax.servlet.ServletRequestIOExceptionpublic String getRealPath(String path)
getRealPath in interface javax.servlet.ServletRequestpublic String getRemoteAddr()
getRemoteAddr in interface javax.servlet.ServletRequestpublic String getRemoteHost()
getRemoteHost in interface javax.servlet.ServletRequestpublic int getRemotePort()
getRemotePort in interface javax.servlet.ServletRequestpublic String getRemoteUser()
getRemoteUser in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher in interface javax.servlet.ServletRequestpublic String getRequestedSessionId()
getRequestedSessionId in interface javax.servlet.http.HttpServletRequestpublic String getRequestURI()
getRequestURI in interface javax.servlet.http.HttpServletRequestpublic StringBuffer getRequestURL()
getRequestURL in interface javax.servlet.http.HttpServletRequestpublic Response getResponse()
public StringBuilder getRootURL()
Because this method returns a StringBuffer, not a string, you can modify the URL easily, for example, to append path and query parameters.
This method is useful for creating redirect messages and for reporting errors.
public String getScheme()
getScheme in interface javax.servlet.ServletRequestpublic String getServerName()
getServerName in interface javax.servlet.ServletRequestpublic int getServerPort()
getServerPort in interface javax.servlet.ServletRequestpublic javax.servlet.ServletContext getServletContext()
getServletContext in interface javax.servlet.ServletRequestpublic String getServletName()
public String getServletPath()
getServletPath in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.ServletResponse getServletResponse()
public javax.servlet.http.HttpSession getSession()
getSession in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession getSession(boolean create)
getSession in interface javax.servlet.http.HttpServletRequestpublic SessionManager getSessionManager()
public long getTimeStamp()
public Buffer getTimeStampBuffer()
public HttpURI getUri()
public UserIdentity getUserIdentity()
public UserIdentity getResolvedUserIdentity()
Authentication is not Authentication.User (eg.
Authentication.Deferred).public UserIdentity.Scope getUserIdentityScope()
public Principal getUserPrincipal()
getUserPrincipal in interface javax.servlet.http.HttpServletRequestpublic long getDispatchTime()
public boolean isHandled()
public boolean isAsyncStarted()
isAsyncStarted in interface javax.servlet.ServletRequestpublic boolean isAsyncSupported()
isAsyncSupported in interface javax.servlet.ServletRequestpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequestpublic boolean isRequestedSessionIdValid()
isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequestpublic boolean isSecure()
isSecure in interface javax.servlet.ServletRequestpublic boolean isUserInRole(String role)
isUserInRole in interface javax.servlet.http.HttpServletRequestpublic javax.servlet.http.HttpSession recoverNewSession(Object key)
protected void recycle()
public void removeAttribute(String name)
removeAttribute in interface javax.servlet.ServletRequestpublic void removeEventListener(EventListener listener)
public void saveNewSession(Object key, javax.servlet.http.HttpSession session)
public void setAsyncSupported(boolean supported)
public void setAttribute(String name, Object value)
setAttribute in interface javax.servlet.ServletRequestpublic void setAttributes(Attributes attributes)
public void setAuthentication(Authentication authentication)
authentication - the authentication to setpublic void setCharacterEncoding(String encoding) throws UnsupportedEncodingException
setCharacterEncoding in interface javax.servlet.ServletRequestUnsupportedEncodingExceptionpublic void setCharacterEncodingUnchecked(String encoding)
protected final void setConnection(AbstractHttpConnection connection)
public void setContentType(String contentType)
public void setContext(ContextHandler.Context context)
context - context objectpublic boolean takeNewContext()
takeNewContext() since the last
setContext(org.eclipse.jetty.server.handler.ContextHandler.Context) call.public void setContextPath(String contextPath)
HttpServletRequest.getContextPath()public void setCookies(javax.servlet.http.Cookie[] cookies)
cookies - The cookies to set.public void setDispatcherType(javax.servlet.DispatcherType type)
public void setHandled(boolean h)
public void setMethod(String method)
method - The method to set.public void setParameters(MultiMap<String> parameters)
parameters - The parameters to set.public void setPathInfo(String pathInfo)
pathInfo - The pathInfo to set.public void setProtocol(String protocol)
protocol - The protocol to set.public void setQueryEncoding(String queryEncoding)
queryEncoding - public void setQueryString(String queryString)
queryString - The queryString to set.public void setRemoteAddr(String addr)
addr - The address to set.public void setRemoteHost(String host)
host - The host to set.public void setRequestedSessionId(String requestedSessionId)
requestedSessionId - The requestedSessionId to set.public void setRequestedSessionIdFromCookie(boolean requestedSessionIdCookie)
requestedSessionIdCookie - The requestedSessionIdCookie to set.public void setRequestURI(String requestURI)
requestURI - The requestURI to set.public void setScheme(String scheme)
scheme - The scheme to set.public void setServerName(String host)
host - The host to set.public void setServerPort(int port)
port - The port to set.public void setServletPath(String servletPath)
servletPath - The servletPath to set.public void setSession(javax.servlet.http.HttpSession session)
session - The session to set.public void setSessionManager(SessionManager sessionManager)
sessionManager - The sessionManager to set.public void setTimeStamp(long ts)
public void setUri(HttpURI uri)
uri - The uri to set.public void setUserIdentityScope(UserIdentity.Scope scope)
public void setDispatchTime(long value)
value - timestamppublic javax.servlet.AsyncContext startAsync()
throws IllegalStateException
startAsync in interface javax.servlet.ServletRequestIllegalStateExceptionpublic javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse)
throws IllegalStateException
startAsync in interface javax.servlet.ServletRequestIllegalStateExceptionpublic boolean authenticate(javax.servlet.http.HttpServletResponse response)
throws IOException,
javax.servlet.ServletException
authenticate in interface javax.servlet.http.HttpServletRequestIOExceptionjavax.servlet.ServletExceptionpublic javax.servlet.http.Part getPart(String name) throws IOException, javax.servlet.ServletException
getPart in interface javax.servlet.http.HttpServletRequestIOExceptionjavax.servlet.ServletExceptionpublic Collection<javax.servlet.http.Part> getParts() throws IOException, javax.servlet.ServletException
getParts in interface javax.servlet.http.HttpServletRequestIOExceptionjavax.servlet.ServletExceptionpublic void login(String username, String password) throws javax.servlet.ServletException
login in interface javax.servlet.http.HttpServletRequestjavax.servlet.ServletExceptionpublic void logout()
throws javax.servlet.ServletException
logout in interface javax.servlet.http.HttpServletRequestjavax.servlet.ServletExceptionpublic void mergeQueryString(String query)
setParameters(MultiMap) and
setQueryString(String) are called with the result. The merge is according to the rules of the servlet dispatch forward method.query - The query string to merge into the request.Copyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.