⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 httpservlet.html

📁 j2ee帮助文档软件设计/软件工程 文件格式
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<DD><DL><DT><B>Parameters:</B><DD><CODE>req</CODE> - the <code>HttpServletRequest</code>                         object that is sent to the servlet<DT><B>Returns:</B><DD>a <code>long</code> integer specifying                        the time the <code>HttpServletRequest</code>                        object was last modified, in milliseconds                        since midnight, January 1, 1970 GMT, or                        -1 if the time is not known</DL></DD></DL><HR><A NAME="doHead(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)"><!-- --></A><H3>doHead</H3><PRE>protected void <B>doHead</B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http">HttpServletRequest</A>&nbsp;req,                      <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A>&nbsp;resp)               throws <A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A>,                      <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD><p>Receives an HTTP HEAD request from the protected <code>service</code> method and handles the request. The client sends a HEAD request when it wants to see only the headers of a response, such as Content-Type or Content-Length. The HTTP HEAD method counts the output bytes in the response to set the Content-Length header accurately. <p>If you override this method, you can avoid computing the response body and just set the response headers directly to improve performance. Make sure that the <code>doHead</code> method you write is both safe and idempotent (that is, protects itself from being called multiple times for one HTTP HEAD request). <p>If the HTTP HEAD request is incorrectly formatted, <code>doHead</code> returns an HTTP "Bad Request" message.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>req</CODE> - the request object that is passed                        to the servlet<DD><CODE>resp</CODE> - the response object that the servlet                        uses to return the headers to the clien<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output error occurs<DD><CODE><A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A></CODE> - if the request for the HEAD                                        could not be handled</DL></DD></DL><HR><A NAME="doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)"><!-- --></A><H3>doPost</H3><PRE>protected void <B>doPost</B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http">HttpServletRequest</A>&nbsp;req,                      <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A>&nbsp;resp)               throws <A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A>,                      <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Called by the server (via the <code>service</code> method) to allow a servlet to handle a POST request. The HTTP POST method allows the client to send data of unlimited length to the Web server a single time and is useful when posting information such as credit card numbers. <p>When overriding this method, read the request data, write the response headers, get the response's writer or output stream object, and finally, write the response data. It's best  to include content type and encoding. When using a <code>PrintWriter</code> object to return the response, set the  content type before accessing the <code>PrintWriter</code> object.  <p>The servlet container must write the headers before committing the response, because in HTTP the headers must be sent before the  response body. <p>Where possible, set the Content-Length header (with the <A HREF="../../../javax/servlet/ServletResponse.html#setContentLength(int)"><CODE>ServletResponse.setContentLength(int)</CODE></A> method), to allow the servlet container to use a persistent connection  to return its response to the client, improving performance. The content length is automatically set if the entire response fits inside the response buffer.   <p>When using HTTP 1.1 chunked encoding (which means that the response has a Transfer-Encoding header), do not set the Content-Length header.  <p>This method does not need to be either safe or idempotent. Operations requested through POST can have side effects for which the user can be held accountable, for example,  updating stored data or buying items online. <p>If the HTTP POST request is incorrectly formatted, <code>doPost</code> returns an HTTP "Bad Request" message.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>req</CODE> - an <A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http"><CODE>HttpServletRequest</CODE></A> object that                        contains the request the client has made                        of the servlet<DD><CODE>resp</CODE> - an <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http"><CODE>HttpServletResponse</CODE></A> object that                        contains the response the servlet sends                        to the client<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output error is                                 detected when the servlet handles                                the request<DD><CODE><A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A></CODE> - if the request for the POST                                        could not be handled<DT><B>See Also:</B><DD><A HREF="../../../javax/servlet/ServletOutputStream.html" title="class in javax.servlet"><CODE>ServletOutputStream</CODE></A>, <A HREF="../../../javax/servlet/ServletResponse.html#setContentType(java.lang.String)"><CODE>ServletResponse.setContentType(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)"><!-- --></A><H3>doPut</H3><PRE>protected void <B>doPut</B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http">HttpServletRequest</A>&nbsp;req,                     <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A>&nbsp;resp)              throws <A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A>,                     <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Called by the server (via the <code>service</code> method) to allow a servlet to handle a PUT request. The PUT operation allows a client to  place a file on the server and is similar to  sending a file by FTP. <p>When overriding this method, leave intact any content headers sent with the request (including Content-Length, Content-Type, Content-Transfer-Encoding, Content-Encoding, Content-Base, Content-Language, Content-Location, Content-MD5, and Content-Range). If your method cannot handle a content header, it must issue an error message (HTTP 501 - Not Implemented) and discard the request. For more information on HTTP 1.1, see RFC 2616 <a href="http://www.ietf.org/rfc/rfc2616.txt"></a>. <p>This method does not need to be either safe or idempotent. Operations that <code>doPut</code> performs can have side effects for which the user can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage. <p>If the HTTP PUT request is incorrectly formatted, <code>doPut</code> returns an HTTP "Bad Request" message.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>req</CODE> - the <A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http"><CODE>HttpServletRequest</CODE></A> object that                        contains the request the client made of                        the servlet<DD><CODE>resp</CODE> - the <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http"><CODE>HttpServletResponse</CODE></A> object that                        contains the response the servlet returns                        to the client<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output error occurs                                while the servlet is handling the                                PUT request<DD><CODE><A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A></CODE> - if the request for the PUT                                        cannot be handled</DL></DD></DL><HR><A NAME="doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)"><!-- --></A><H3>doDelete</H3><PRE>protected void <B>doDelete</B>(<A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http">HttpServletRequest</A>&nbsp;req,                        <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http">HttpServletResponse</A>&nbsp;resp)                 throws <A HREF="../../../javax/servlet/ServletException.html" title="class in javax.servlet">ServletException</A>,                        <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></PRE><DL><DD>Called by the server (via the <code>service</code> method) to allow a servlet to handle a DELETE request. The DELETE operation allows a client to remove a document or Web page from the server.  <p>This method does not need to be either safe or idempotent. Operations requested through DELETE can have side effects for which users can be held accountable. When using this method, it may be useful to save a copy of the affected URL in temporary storage. <p>If the HTTP DELETE request is incorrectly formatted, <code>doDelete</code> returns an HTTP "Bad Request" message.<P><DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>req</CODE> - the <A HREF="../../../javax/servlet/http/HttpServletRequest.html" title="interface in javax.servlet.http"><CODE>HttpServletRequest</CODE></A> object that                        contains the request the client made of                        the servlet<DD><CODE>resp</CODE> - the <A HREF="../../../javax/servlet/http/HttpServletResponse.html" title="interface in javax.servlet.http"><CODE>HttpServletResponse</CODE></A> object that                        contains the response the servlet returns                        to the client<DT><B>Throws:</B><DD><CODE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/io/IOException.html" title="class or interface in java.io">IOException</A></CODE> - if an input or output error occurs                                while the servlet is handling the

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -