intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Java Server Pages: A Code-Intensive Premium Reference- P23

Chia sẻ: Cong Thanh | Ngày: | Loại File: PDF | Số trang:10

39
lượt xem
5
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Java Server Pages: A Code-Intensive Premium Reference- P23:Before you begin reading Pure JSP Java Server Pages, you might want to take a look at its basic structure. This should help you outline your reading plan if you choose not to read the text from cover to cover. This introduction gives you an overview of what each chapter covers.

Chủ đề:
Lưu

Nội dung Text: Java Server Pages: A Code-Intensive Premium Reference- P23

  1. This version of the println() method prints the passed in int value to the output stream, followed by a CRLF. Parameters int println(long value) Method public void println(long value) throws java.io.IOException This version of the println() method prints the passed in long value to the output stream, followed by a CRLF. Parameters long println(float value) Method public void println(float value) throws java.io.IOException This version of the println() method prints the passed in float value to the output stream, followed by a CRLF. Parameters float println(double value) Method public void println(double value) throws java.io.IOException This version of the println() method prints the passed in double value to the output stream, followed by a CRLF. Parameters double Chapter 21: The javax.servlet.http Package Overview The java.servlet.http package contains the interfaces and classes that are implemented and extended, respectively, to create HTTP-specific servlets. Figure 21.1 contains the javax.servlet.http object model. - 221 -
  2. Figure 21.1: The javax.servlet.http object model. Interfaces Interfaces for the java.servlet.http package are HttpServletRequest, HttpServletResponse, HttpSession, and HttpSessionBindingListener. HttpServletRequest Interface public interface HttpServletRequest extends ServletRequest The HttpServletRequest interface defines an object that provides the HttpServlet.service() method with access to HTTP-protocol–specific header information sent by the client. The HttpServletRequest interface has 26 methods, described in the following sections. addHeader() Method public void addHeader(java.lang.String name, java.lang.String value) The addHeader() method adds another value to the response for the given header. addHeader() returns no value and throws no exceptions. Parameters java.lang.String java.lang.String addDateHeader() Method public void addDateHeader(java.lang.String name, long date) The addDateHeader() method adds another date value to the response for the given header. addDateHeader() returns no value and throws no exceptions. Parameters java.lang.String - 222 -
  3. long addIntHeader() Method public void addIntHeader(java.lang.String name, int value) The addIntHeader() method adds another int value to the response for the given header. addIntHeader() returns no value and throws no exceptions. Parameters java.lang.String int getAuthType() Method public java.lang.String getAuthType() The getAuthType() method returns the authentication scheme used in this request. It is the same as the AUTH_TYPE CGI variable. getAuthType() has no parameters and throws no exceptions. Returns java.lang.String getContextPath() Method public java.lang.String getContextPath() The getContextPath() method returns the context path of this request. getContextPath() has no parameters and throws no exceptions. Returns java.lang.String getCookies() Method public Cookie[] getCookies() The getCookies() method returns an array of Cookie objects found in the client request. getCookies() has no parameters and throws no exceptions. Returns Cookie[] getDateHeader() Method public long getDateHeader(java.lang.String name) The getDateHeader() method returns the value of the requested date header field found in the client request. getDateHeader() throws no exceptions. Parameters java.lang.String Returns long getHeader() Method public java.lang.String getHeader(java.lang.String name) The getHeader() method returns the value of the requested header field found in the client request. getHeader() throws no exceptions. Parameters java.lang.String Returns java.lang.String - 223 -
  4. getHeaders() Method public Enumeration getHeaders(java.lang.String name) The getHeaders() method returns an Enumeration of Strings containing all of the values for the given header. getHeaders() throws no exceptions. Parameters java.lang.String Returns Enumeration getHeaderNames() Method public Enumeration getHeaderNames() The getHeaderNames() method returns an Enumeration containing all of the header names found in the client request. getHeaderNames() has no parameters and throws no exceptions. Returns Enumeration getIntHeader() Method public int getIntHeader(java.lang.String name) The getIntHeader() method returns the int value of the named header field, found in the client request. getIntHeader() throws no exceptions. Parameters java.lang.String Returns int getMethod() Method public java.lang.String getMethod() The getMethod() method returns the HTTP method used by the client request. It is the same as the CGI variable REQUEST_METHOD. getMethod() has no parameters and throws no exceptions. Returns java.lang.String getPathInfo() Method public java.lang.String getPathInfo() The getPathInfo() method returns a String containing any additional path information following the servlet path, but preceding the query string. It is the same as the CGI variable PATH_INFO. getPathInfo() has no parameters and throws no exceptions. Returns java.lang.String getPathTranslated() Method public java.lang.String getPathTranslated() The getPathTranslated() method returns the same information as the getPathInfo() method, but translates the path to its real path name before returning it. It is the same as the CGI variable PATH_TRANSLATED. getPathTranslated() has no parameters and throws no exceptions. - 224 -
  5. Returns java.lang.String getQueryString() Method public java.lang.String getQueryString() The getQueryString() method returns the query string from the request. It is the same as the CGI variable QUERY_STRING. getQueryString() has no parameters and throws no exceptions. Returns java.lang.String getRemoteUser() Method public java.lang.String getRemoteUser() The getRemoteUser() method returns the name of the user making the request. If the name is not available, null is returned. It is the same as the CGI variable REMOTE_USER. getRemoteUser() has no parameters and throws no exceptions. Returns java.lang.String getRequestedSessionId() Method public java.lang.String getRequestedSessionId() The getRequestedSessionId() method returns the session id associated with the request. getRequestedSessionId() has no parameters and throws no exceptions. Returns java.lang.String getRequestURI() Method public java.lang.String getRequestURI() The getRequestURI() method returns the first line of the request's URI. This is the part of the URI that is found to the left of the query string. getRequestURI() has no parameters and throws no exceptions. Returns java.lang.String getUserPrincipal() Method public java.security.Principal getUserPrincipal() The getUserPrincipal() method returns the Principal of the user making the request. getUserPrincipal() has no parameters and throws no exceptions. Returns java.security.Principal getServletPath() Method public java.lang.String getServletPath() The getServletPath() method returns the part of the URI that refers to the servlet being invoked. getServletPath() has no parameters and throws no exceptions. Returns java.lang.String getSession(boolean create) Method public HttpSession getSession(boolean create) - 225 -
  6. The getSession() method returns the session associated with the request. If there is no valid session and the boolean parameter passed in is true, then it will create a new session. getSession() throws no exceptions. Parameters boolean Returns HttpSession getSession() Method public HttpSession getSession() The getSession() method performs the same as the previous getSession() method; it just performs as if it was always passed a true value. getSession() has no parameters and throws no exceptions. Returns HttpSession isRequestedSessionValid() Method public boolean isRequestedSessionValid() The isRequestedSessionValid() method returns true if the session is valid in the current context; otherwise, it returns false. isRequestedSessionValid() has no parameters and throws no exceptions. Returns boolean isRequestedSessionFromCookie() Method public boolean isRequestedSessionFromCookie() The isRequestedSessionFromCookie() method returns true if the session id from the request came in as a cookie; otherwise, it returns false. isRequestedSessionFromCookie() has no parameters and throws no exceptions. Returns boolean isRequestedSessionFromURL() Method public boolean isRequestedSessionFromURL() The isRequestedSessionFromURL() method returns true if the session id from the request came in as part of the URL; otherwise, it returns false. isRequestedSessionFromURL() has no parameters and throws no exceptions. Returns boolean HttpServletResponse Interface public interface HttpServletResponse extends ServletRequest The HttpServletResponse interface defines an object that provides the HttpServlet.service() method with the capability to manipulate HTTP-protocol– specific header information and return data to the client. The HttpServletResponse interface has 39 fields and 10 methods, described in following sections. - 226 -
  7. SC_CONTINUE Field public static final int SC_CONTINUE This field represents a status code of (100), indicating that the client can continue. SC_SWITCHING_PROTOCOLS Field public static final int SC_SWITCHING_PROTOCOLS This field represents a status code of (101), indicating the server is switching protocols according to the Upgrade header. SC_OK Field public static final int SC_OK This field represents a status code of (200), indicating the request succeeded normally. SC_CREATED Field public static final int SC_CREATED This field represents a status code of (201), indicating the request succeeded and created a new resource on the server. SC_ACCEPTED Field public static final int SC_ACCEPTED This field represents a status code of (202), indicating that a request was accepted for processing, but was not completed. SC_NON_AUTHORITATIVE_INFORMATION Field public static final int SC_NON_AUTHORITATIVE_INFORMATION This field represents a status code of (203), indicating that the meta information presented by the client did not originate from the server. SC_NO_CONTENT Field public static final int SC_NO_CONTENT This field represents a status code of (204), indicating that the request succeeded but that there was no new information to return. SC_RESET_CONTENT Field public static final int SC_RESET_CONTENT This field represents a status code of (205), indicating that the agent should reset the document view, which caused the request to be sent. SC_PARTIAL_CONTENT Field public static final int SC_PARTIAL_CONTENT This field represents a status code of (206), indicating that the server has fulfilled the partial GET request for the resource. SC_MULTIPLE_CHOICES Field public static final int SC_MULTIPLE_CHOICES This field represents a status code of (300), indicating that the requested resource corresponds to any one of a set of representations, each with its own specific location. - 227 -
  8. SC_MOVED_PERMANENTLY Field public static final int SC_MOVED_PERMANENTLY This field represents a status code of (301), indicating that the resource has permanently moved to a new location, and that future references should use a new URI with their requests. SC_MOVED_TEMPORARILY Field public static final int SC_MOVED_TEMPORARILY This field represents a status code of (302), indicating that the resource has temporarily moved to another location, but that future references should still use the original URI to access the resource. SC_SEE_OTHER Field public static final int SC_SEE_OTHER This field represents a status code of (303), indicating that the response to the request can be found under a different URI. SC_NOT_MODIFIED Field public static final int SC_NOT_MODIFIED This field represents a status code of (304), indicating that a conditional GET operation found that the resource was available and not modified. SC_USE_PROXY Field public static final int SC_USE_PROXY This field represents a status code of (305), indicating that the requested resource must be accessed through the proxy given by the Location field. SC_BAD_REQUEST Field public static final int SC_BAD_REQUEST This field represents a status code of (400), indicating the request sent by the client was syntactically incorrect. SC_UNAUTHORIZED Field public static final int SC_UNAUTHORIZED This field represents a status code of (401), indicating that the request requires HTTP authentication. SC_PAYMENT_REQUIRED Field public static final int SC_PAYMENT_REQUIRED This field represents a status code of (402) for future use. SC_FORBIDDEN Field public static final int SC_FORBIDDEN This field represents a status code of (403), indicating the server understood the request but refused to fulfill it. SC_NOT_FOUND Field public static final int SC_NOT_FOUND - 228 -
  9. This field represents a status code of (404), indicating that the requested resource is not available. SC_METHOD_NOT_ALLOWED Field public static final int SC_METHOD_NOT_ALLOWED This field represents a status code of (405), indicating that the method specified in the Request-Line is not allowed for the resource identified by the Request-URI. SC_NOT_ACCEPTABLE Field public static final int SC_NOT_ACCEPTABLE This field represents a status code of (406), indicating that the resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request. SC_PROXY_AUTHENTICATION_REQUIRED Field public static final int SC_PROXY_AUTHENTICATION_REQUIRED This field represents a status code of (407), indicating that the client must first authenticate itself with the proxy. SC_REQUEST_TIMEOUT Field public static final int SC_REQUEST_TIMEOUT This field represents a status code of (408), indicating that the client did not produce a request within the time that the server was prepared to wait. SC_CONFLICT Field public static final int SC_CONFLICT This field represents a status code of (409), indicating that the request could not be completed due to a conflict with the current state of the resource. SC_GONE Field public static final int SC_GONE This field represents a status code of (410), indicating that the resource is no longer available at the server and no forwarding address is known. This condition should be considered permanent. SC_LENGTH_REQUIRED Field public static final int SC_LENGTH_REQUIRED This field represents a status code of (411), indicating that the request cannot be handled without a defined Content-Length. SC_PRECONDITION_FAILED Field public static final int SC_PRECONDITION_FAILED This field represents a status code of (412), indicating that the precondition given in one or more of the request-header fields evaluated to false when it was tested on the server. SC_REQUEST_ENTITY_TOO_LARGE Field public static final int SC_REQUEST_ENTITY_TOO_LARGE - 229 -
  10. This field represents a status code of (413), indicating that the server is refusing to process the request because the request entity is larger than the server is willing or able to process. SC_REQUEST_URI_TOO_LONG Field public static final int SC_REQUEST_URI_TOO_LONG This field represents a status code of (414), indicating that the server is refusing to service the request because the Request-URI is longer than the server is willing to interpret. SC_UNSUPPORTED_MEDIA_TYPE Field public static final int SC_UNSUPPORTED_MEDIA_TYPE This field represents a status code of (415), indicating that the server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method. SC_INTERNAL_SERVER_ERROR Field public static final int SC_INTERNAL_SERVER_ERROR This field represents a status code of (500), indicating an error inside the HTTP server which prevented it from fulfilling the request. SC_NOT_IMPLEMENTED Field public static final int SC_NOT_IMPLEMENTED This field represents a status code of (501), indicating the HTTP server does not support the functionality needed to fulfill the request. SC_BAD_GATEWAY Field public static final int SC_BAD_GATEWAY This field represents a status code of (502), indicating that the HTTP server received an invalid response from a server it consulted when acting as a proxy or gateway. SC_SERVICE_UNAVAILABLE Field public static final int SC_SERVICE_UNAVAILABLE This field represents a status code of (503), indicating that the HTTP server is temporarily overloaded, and unable to handle the request. SC_GATEWAY_TIMEOUT Field public static final int SC_GATEWAY_TIMEOUT This field represents a status code of (504), indicating that the server did not receive a timely response from the upstream server while acting as a gateway or proxy. SC_HTTP_VERSION_NOT_SUPPORTED Field public static final int SC_HTTP_VERSION_NOT_SUPPORTED This field represents a status code of (505), indicating that the server does not support or refuses to support the HTTP version found in the request. addCookie() Method public void addCookie(Cookie cookie) The addCookie() method adds a Cookie to the HttpServletResponse object. addCookie() throws no exceptions. addCookie() returns no value. - 230 -
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2