File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Diff betwn Get and Post Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Diff betwn Get and Post" Watch "Diff betwn Get and Post" New topic
Author

Diff betwn Get and Post

Manish Jaju
Greenhorn

Joined: Jul 21, 2004
Posts: 24
I have some doubt regarding post and get methods, used to process a request... What I understood, that if parameters append with URL then get is used and to send it hidden, post is used... Is there any other specific reason to use get or post except I mentioned above. Please clarify
gaurav chhabra
Ranch Hand

Joined: Jul 24, 2004
Posts: 109
if someone can catch ur mathord then he can easily trap ur info.in GET but not in POST.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

To me it's more about your intent than their usage. Cryptic, but what I mean is that if you are submitting data, use POST, but if you are sending data to recieve information, use GET.

Examples of the 'POST' type are easy: submitting forms, sending personal info etc.
Example of the GET type are things like catalogues, where you send a product ID to a product page to see that product.

It's as much an art as a science, but I saw a reasonable quote here that said GET should be considered idempotent - that is, it doesn't change the state of the server and repeated calls return the same response (with the exception of page trackers etc).
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Also, note that get is the default if no other method is specified.


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Advantages of GET:

  • Because the params are part of the URL, they can be included in an anchor tag.
  • The params will be retained if the user bookmarks the page (this thread is a good example).

  • Note: This can also be seen as a disadvantage, depending on your needs.
  • The params will show up in the header's 'referer' variable. (This is particularly usefull with Yahoo and Google searches).


  • Advantages of POST:
  • Because the params are not part of the URL, usernames and passwords will not show up, plain text, in the address window of the browser.
  • The browser automatically encodes all the text for you. (Now this is also done for GET requests but with some older browsers, you will need to do this explicitly).
  • With older browsers (Netscape 4.7) there was a 255 character limit to the URL length. If your app has to support older browsers, watch out for this one if you are using GET.
  • You can send any type of data by setting the mime type. Not a big issue with browser apps but usefull for applets.


  • Those are the ones I can think of off the top of my head.
    [ January 24, 2005: Message edited by: Ben Souther ]

    Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Diff betwn Get and Post
     
    Similar Threads
    How to try the HttpMethods
    Tomcat error.
    My Favorite Pets
    Getting wrong result ,but why?
    Valid HTTP Methods for FORM Authentication