aspose file tools*
The moose likes Servlets and the fly likes Advantage of doGet method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Advantage of doGet method ?" Watch "Advantage of doGet method ?" New topic
Author

Advantage of doGet method ?

Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi,

Can any please tell me is there any advantage of doGet method over doPost method.

Thanks & Regards
Bikash
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Yes using doPost method you can send bulk of data. doGet method has some limitations. you can't send over a specific amount of data using doGet. So use doPost method when you want to send a large data like Registeration forms etc.

And when you use doGet the data is shown in query string in your explorer's address bar but in case of doPost the data is not viewable in address bar. So when you want to send the secure data like password or other things like that use doPost.
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi,

First of all thanks for the reply I think u r not getting me I have asked what is the advantage of doGet over doPost.I know the difference of these two method.But my question is if doPost is secure and we can send unlimited data ,then what is the use of doGet method ? why SUN provide this doGet method.I want to know in which situation doGet is more effective than doPost.

Thanks & Regards
Bikash
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
Ok sorry for misunderstanding. There are some situation where we have to use doGet instead of doPost. If you want to make a link for a Servlet or jsp and you want to pass 1 or 2 parameters using href tag of HTML. Then you will have to use doGet. When we write:

<a href="anyservlet?param=blabla">Click Here</a>

in this case it will call the doGet method instead of doPost of servlet.
And if you want to use response.sendRedirect() to a page and you want to use any parameter in that then you will have to use doGet method

response.sendRedirect("anyservlet?param=blabla");

in these kinds of cases we will have to use doGet.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Unless specifically specified in an HTML for ALL HTTP traffic uses GET requests.
Therefore if Sun had not supported GET requests you'd be completely and utterly unable to handle 90% or more of all HTTP traffic.

Simply typing the URI of your servlet in your browser and pressing enter would yield an error "GET not supported" or similar.


42
Bikash Paul
Ranch Hand

Joined: Dec 04, 2001
Posts: 342
Hi,

Lot of thanks for ur clarification.

Thanks & Regards
Bikash
 
 
subject: Advantage of doGet method ?