Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

difference between doGet and doPost methods in servlets

 
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference in doGet and doPost Methods in java
servlets.
can anyone clearly explain
appreciate your help
 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You had not posted your question in a right forum...
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to Servlets...
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic