what is the difference between doGet() and doPost() in term of the flow?

the difference in term of the flow, i know that doGet() is the pre-processing and dopost is post-processing, but what is that?

Actually, the methods are nothing to do with “pre-processing” and “post-processing”.

To understand what the methods are for, you need some basic understand of the HTTP protocol.

HTTP is a request-reply protocol: the client (e.g. a web browser) sends a request, and the server (e.g. a web server) responds with a reply. Each request consists of a “request-line”, a series of “header” lines and optionally a “body”. A typical request-line looks like this:

  GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1

The three parts of this line are:

In fact, the HTTP specification defines 8 standard HTTP request methods (GET, PUT, POST, DELETE, HEAD, OPTIONS, TRACE & CONNECT) each of which has a different meaning. (Other methods are defined by other specifications.)

The doGet and doPost methods in the Servlet API are methods for processing HTTP GET and POST requests respectively. In fact there are other “doXxxx” methods matching the other standard HTTP methods … apart from CONNECT. (The semantics of CONNECT are not applicable to a servlet …)

For more information, refer to the HTTP 1.1 Specification, and the HttpServlet javadoc.

Leave a Comment