wood burning stoves 2.0
The moose likes Servlets and the fly likes difference btw doGet and doPost methods? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "difference btw doGet and doPost methods?" Watch "difference btw doGet and doPost methods?" New topic

difference btw doGet and doPost methods?

Murali Dhar Gandepalli

Joined: Jul 25, 2001
Posts: 2
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

Joined: May 29, 2001
Posts: 113
get method pass query string
post method pass form data

Senior software engineer
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

"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().

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: difference btw doGet and doPost methods?
It's not a secret anymore!