Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

difference btw doGet and doPost methods?

 
Murali Dhar Gandepalli
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when my code went undergone review the comments said that usage of doGet( has to be minimum.
I know that doGet has to be used when we need to retrive some data from database (which is not confidential).Otherwise use doPost.
Can some body guide me when to use doGet or doPost ?
When I passing data from HTML(Browser) to a Servelet(Server),in building the messages which one will tak more time ?
 
Dorj Galaa
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
get method pass query string
post method pass form data
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18160
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"GET" is useful for short requests. It's the older of the two forms and is convenient because it's actually displayed in the "Location" textbox on your web browser, so you can tweak it.
"POST" is better for long requests, requests where you don't WANT the user to see what you're passing to the servlet/JSP, and cases where you are doing a lot of work and don't want 9700 similar-but-not-identical pages listed on your browser's history.
"POST" streams are allowed to be indefinitely long, where as "GET"s are limited to a buffer size - the infamous "code red" worm took advantage of this fact by issuing a GET request so long that it slopped out of the server's buffer and into an area where it could become executable code.
A lot of times during debugging, I flip from POST to GET just to be able to see and play with the page request. since I have doGet() forwarding to doPost().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic