Detailed HttpServletRequest class

Disclaimer: This article is a blogger original article, reproduced, please attach Bowen link! https://blog.csdn.net/f2764052703/article/details/89432259

HttpServletRequest is an extension of an interface javax.servlet.ServletRequest provide for the HTTP servlet request related information.
The servlet container creates HttpServletRequest object, and the object is passed to the service method of the servlet (doGet, doPost, etc.) as parameters.

method effect parameter return value
getAuthType() Returns the name of protecting the servlet authentication scheme used. no String, returns the static member BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, one DIGEST_AUTH (== suitable for comparison) or return to the authentication scheme specified character string indicating the container, if no authentication request, null is returned.
getContextPath() URI acquisition request indicating that a portion of the request context no String, String indicating a request URI that part of the designation request context
getCookies() Obtaining an array of all the objects contained Cookie client together with this request no Cookie[]
getDateHeader(String name) Date object in the form of a long value returns the value of the specified request header String, String specifies the name of the head It represents a long value dates specified in the header
getHeader(String name) Returns a String request header value String, String specifies the name of the head String, String containing the request header
getHeaders(String name) Returns an Enumeration String object request header of all values. Specifies the name of the head of String Enumeration, comprising a request header Enumeration
getHeaderNames() Returns an enumeration of all the header names this request contains no Enumerate all first names together with this request
getIntHeader(String name) Head returns an int String name of the specified request header It represents an integer in the request header
getMethod() Obtaining request mode request no String method name designated for issuing this request
getPathInfo() Additional paths associated with the URL is sent when making this request and client information no Decoded by the Web container String, path information for designating additional
getPathTranslated() Return after the servlet name but extra path information before the query string, and converts it to an actual path no String specify the actual path
getContextPath() Returns the request URI indicating that a portion of the request context no String Specifies the request URI indicates the portion of the request context
getQueryString() Query string contained in the request URL path behind no String containing the query string
getRemoteUser() If the user has been validated, the login information of the user making this request is returned if the user is not verified, null is returned no Specifies the user issuing this request login information String
getRequestedSessionId() Returns the session ID specified by the client no String specified session ID
getRequestURI() Returns this part of the request URL from the protocol name up to the query string in the first line of the HTTP request no String that contains part of the URL from the protocol name up to the query string
getRequestURL() Reconstruct the client requesting the URL no StringBuffer object containing the reconstructed URL
getServletPath() Return to this part of the request URL calls the servlet no String name or path comprises a servlet is invoked or decoded (e.g., as specified in the URL request)
getSession(boolean create) 返回与此请求关联的当前 HttpSession,如果没有当前会话并且 create 为 true,则返回一个新会话 true 表示为此请求创建一个新会话(如有必要);false 表示返回 null(如果没有当前会话) 与此请求关联的 HttpSession,如果 create 为 false,并且该请求没有有效会话,则返回 null
getSession() 返回与此请求关联的当前会话,如果该请求没有会话,则创建一个会话 与此请求关联的 HttpSession
isRequestedSessionIdValid() 检查请求的会话 ID 是否仍然有效。 如果此请求在当前会话上下文中有一个有效会话 id,则返回 true;否则返回 false
isRequestedSessionIdFromCookie() 检查请求的会话 ID 是否是作为 cookie 进入的。 如果会话 ID 是作为 cookie 进入的,则返回 true;否则返回 false
isRequestedSessionIdFromURL() 检查请求的会话 ID 是否是作为请求 URL 的一部分进入的。 如果会话 ID 是作为 URL 的一部分进入的,则返回 true;否则返回 false

Guess you like

Origin blog.csdn.net/f2764052703/article/details/89432259