-
Expert Member
doGet() & doPost()
what are doGet() & doPost() methods and what is difference between doGet () and doPost()?
This is the question asked by visitor RAVI R K]
-
Contributing Member
Re: doGet() & doPost()
The doGet and doPost methods are called in response to an HTTP GET and an HTTP POST respectively which are submission methods used in an HTML FORM. On an HTTP GET the form data is part of the URL whereas on an HTTP POST the form data appears in the message body. You should always have one method call the other in your servlet as processing the form data in a servlet is consistent regardless of the submission method. For example:
public void doGet(HttpServletRequest req, HttpServletResponse resp)
{
doPost(req,resp);
}
public void doPost(HttpServletRequest req, HttpServletResponse resp)
{
//process the incoming request
}
Difference between doGet and doPost mehtods......
DoGet
1)In doGet Method the parameters are appended to the URL and sent along with header information
2)Maximum size of data that can be sent using doget is 240 bytes
3)Parameters are not encrypted
4)DoGet is faster if we set the response content length since the same connection is used. 5)Thus increasing the performance
6)DoGet should be idempotent. i.e. doget should be able to be repeated safely many times
7)DoGet should be safe without any side effects for which user is held responsible
DoPost
1)In doPost, parame
ters are sent in separate line in the body
2)There is no maximum size for data
3)Parameters are encrypted
4)Dopost is generally used to update or post some information to the server
5)DoPost is slower compared to doGet since doPost does not write the content length
6)This method does not need to be 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
7)This method does not need to be either safe
I think its useful for u.....
--------------------------------------
suresh
-
Contributing Member
-
Junior Member
Re: doGet() & doPost()
[QUOTE=JobHelper;3397]what are doGet() & doPost() methods and what is difference between doGet () and doPost()?
doGet,do post are the methods avilable in HttpServlet Class
doGet():- is used to get the information from the servlet
doPost():- is used to post the information in the servlets
Chheers,
Kailash
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules