wood burning stoves 2.0*
The moose likes Servlets and the fly likes doGet() and doPost() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "doGet() and doPost()" Watch "doGet() and doPost()" New topic
Author

doGet() and doPost()

Sowjanya Chowdary
Ranch Hand

Joined: Aug 22, 2005
Posts: 35
Can anybody please explain me what is the difference between doGet() and doPost() methods in form tag's action?
I am really confused when to use doGet and when doPost().
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
http://www.esus.com/javaindex/j2ee/servlets/servletdogetdopost.html

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

Moved to the Servlets forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
michel knight
Greenhorn

Joined: Nov 23, 2005
Posts: 2
when you just use one servlet to do simple things. you can do it like me:

public class testservlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doService(request,response);
}

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doService(request,response);
}

public void doService(HttpServletRequest
request,HttpServletResponseresponse)
throws ServletException, IOException {
//put your code here
}
}

when you dont know what time do doGet() and what time do doPost(),just do it like me


A fly and flea flew into a flue.said the fly to the flea "what shall we do?". "shall we fly?" said the flea. "let's flee!" said the fly. so they flee through a flow in flue.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

"Amrutha Ch",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
Sowjanya Chowdary
Ranch Hand

Joined: Aug 22, 2005
Posts: 35
Eric Pascarello,
Thanks for the reply. It has been a useful link.

Bear Bibeault,
I had adjusted my display name. Hope it is obeys JavaRanch Naming Policy now.
ranjan kumar panda
Greenhorn

Joined: Nov 27, 2005
Posts: 2
Hi,
Amrutha, I think you did not get the right answer to your question even not in the link given to you. This is how it works.
---doGet() is to generally get some data rather than posting data. But we generally use doGet() as to post a very small amount of data to the server to let the server know what kind of data we are expecting to get as a responce. As data volume is very small mostly upto 240 characters it is just appended in the requested URL (Query String).Once we send that small amount of data to the server there is no constraint in getting any volume of data.
---- On the other hand, doPost() method is generally meant for posting data of large volume to the server. You can post unlimited amount of data to the server which is carried forward with a request object. So the query string does not change.
This is the basic thing behind it. If you want more then send me querries.
Sowjanya Chowdary
Ranch Hand

Joined: Aug 22, 2005
Posts: 35
Thanks Ranjan.
 
jQuery in Action, 2nd edition
 
subject: doGet() and doPost()
 
Similar Threads
POST or GET
doGet,doPost
invoking a servlet from client Java code
doPost and doGet
doGet() & doPost