Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between doGet and doPost methods in servlets  RSS feed

 
Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference in doGet and doPost Methods in java
servlets.
can anyone clearly explain
appreciate your help
 
Uma Viswanathan
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You had not posted your question in a right forum...
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to Servlets...
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Gerry Giese
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/j2ee/j2sdkee/techdocs/api/index.html
Or, more specifically:
http://java.sun.com/j2ee/j2sdkee/techdocs/api/javax/servlet/http/HttpServlet.html
This is basic stuff - I would suggest getting (and reading) a book on Servlets or finding some online tutorials about servlets (java.sun.com just happens to have several). It will save you a lot of grief and answer a lot of your questions.
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a GET request.

protected void doPost(HttpServletRequest req,
HttpServletResponse resp)
Called by the server (via the service method) to allow a servlet to handle a POST request. The HTTP POST method allows the client to send data of unlimited length to the Web server a single time and is useful when posting information such as credit card numbers.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

For examples of what GET and POST look like, check this:
http://www.javaranch.com/ubb/Forum7/HTML/006990.html

short version:
any 'normal' request (like if you click the link above) is a GET
If you are submitting a form, depending on the method attribute of your HTML form, you either GET or POST that data.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!