doGet()与doPost()区别

After the servlet is initialized, the container may keep it ready for handling client
requests. When client requests arrive, they are delegated to the servlet through the
service()method, passing the request and response objects as parameters. In the
case of HTTP requests, the request and response objects are implementations of
HttpServletRequest and HttpServletResponse respectively. In the
HttpServlet class, the service() method invokes a different handler method for
each type of HTTP request, doGet() method for GET requests, doPost() method for
POST requests, and so on.


some more,


GET method

The GET method is used to retrieve a resource (like an image or an HTML page) from
the server, which is specified in the request URL. When the user types the request
URL into the browser's location field or clicks on a hyperlink, the GET method is
triggered. If a tag is used, the method attribute can be specified as "GET" to cause the
browser to send a GET request. Even if no method attribute is specified, the browser
uses the GET method by default.
We can pass request parameters by having a query string appended to the request
URL, which is a set of name-value pairs separated by an "&" character. Here we have passed the parameters studname and studno, which have the values
"Tom" and "123" respectively. Because the data passed using the GET method is
visible inside the URL, it is not advisable to send sensitive information in this manner.
The other restrictions for the GET method are that it can pass only text data and not more than 255 characters (i read somewhere that it depends on browser support).


POST method
The purpose of the POST method is to "post" or send information to the server. It is
possible to send an unlimited amount of data as part of a POST request, and the type of
data can be binary or text.
This method is usually used for sending bulk data, such as uploading files or updating
databases. The method attribute of the <form> tag can be specified as "POST" to
cause the browser to send a POST request to the server.
Because the request parameters are sent as part of the request body, it is not visible
as part of the request URL, which was also the case with the GET method.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值