File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet" Watch "servlet" New topic


Shrawan Bhageria
Ranch Hand

Joined: Jun 20, 2005
Posts: 52
pl. anyone tell me about use of this code in servlet.

thanks in advance

public void doGet(HttpServletRequest req, HttpServletResponse res) {

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

There are multiple 'methods' in HTTP which you can use to call web respources. GET and POST and the most common.

'Typically' (and this is a bit of a generalisation) resources get called using 'GET', although the actual method in some cases is not important. In the case where you don't care, some people allow the same piece of code to execute for both the 'GET' and 'POST' calls.

It is eqivalent to:

Personally I don't do this. Servlets respond to GET, POST, or both, but when it responds to both it behaves differently for each. Others will disagree.

moh sak
Ranch Hand

Joined: May 11, 2005
Posts: 78
Originally posted by Shrawan Bhageria:

i think you mean dePost(req,res);

when you submit data and you dont want them to appear in the url you call the doPost method because the doGet method shows every thing in the url.

hope this help you
I agree. Here's the link:
subject: servlet
It's not a secret anymore!