Receives an HTTP POST request from the protected
service
method and handles the request.
The HTTP POST method allows the client to send
data of unlimited length to the Web server once
and is useful when posting information such as
credit card numbers.
If you override this method, you should read data from
the HttpServletRequest
object, set headers
for the response (including Content-Type and Content-Encoding),
access a PrintWriter
or
output stream object, and then write any response data
using a ServletOutputStream
object.
If you use a PrintWriter
object to
write response data, set the Content-Type header before
you access the PrintWriter
object.
The servlet engine must write the headers before the
the response data, because the headers can be flushed at
any time after the servlet engine begins to write the body
of the response.
If you use HTTP 1.1 chunked encoding (which means that
the response has a Transfer-Encoding header), do not set the
Content-Length header. If you do not use
chunked encoding, set the content length to allow the servlet
to take advantage of the HTTP "connection keep alive" feature,
If you cannot set the content length and therefore cannot
use "keep alive," you may be able to avoid the performance
penalty if the response fits in an internal buffer.
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.
If the HTTP POST request is incorrectly formatted,
doPost
returns an HTTP BAD_REQUEST message.
- Overrides:
- doPost in class javax.servlet.http.HttpServlet
Tags copied from class: javax.servlet.http.HttpServlet
- Parameters:
req
- an HttpServletRequest
object that
contains the request the client has made
of the servletresp
- an HttpServletResponse
object that
contains the response the servlet sends
to the object- Throws:
- java.io.IOException - if an input or output error is
detected when the servlet handles
the request
- javax.servlet.ServletException - if the request for the POST
could not be handled
- See Also:
ServletOutputStream
,
ServletResponse.setContentType(java.lang.String)