doGet is here to process http GET request, so if you think that you don't need it (for example if you want to treat only POST requests), you don't have to override it.
Hi , As per the servlet specs DoGet is not a must .If you do not want anyone to access the servlet via typing the URL in the address bar you could just implement the DoPost method and inb the Form method tag that would call this servlet mention it as "Post"
rex tony
Ranch Hand
Joined: Aug 29, 2007
Posts: 157
posted
But some time doPost() {doGet()} Calling like this?.What is the reason for that?
sarathchandra chandala
Greenhorn
Joined: Sep 06, 2007
Posts: 9
posted
when we want to provide both the services, we generally use like the above .
David O'Meara
Sheriff
Joined: Mar 06, 2001
Posts: 12332
posted
Originally posted by sarathchandra chandala: when we want to provide both the services, we generally use like the above .
Not quite, when you want both GET and POST to behave the same, you can do that. In practice I try to avoid it. It is completely valid to have them behave differently.
Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems. Jamie Zawinski [JavaRanch FAQ] [Book Promotions] [DbTamer]
Ulf Dittmer
Sheriff
Joined: Mar 22, 2005
Posts: 28826
posted
Originally posted by David O'Meara: It is completely valid to have them behave differently.
And to take this a step further, if you want to create a servlet that behaves according to the HTTP specification, then GET and POST should do different things.
Traditionally there where distinct uses for GET, POST and other HTTP message types, but over time many have fallen into rare usage and GET and POST have often been treated as interchangeable.
Going back to their original intents, GET was designed to be used for 'repeatable' requests, commonly called 'idempotent'. If you browse a catalogue, all 'browse' operations would be expected to be repeatable.
POST operations would involve state changes and not designed for repeating. Logging in, purchasing, registering etc would be POST operations.
While both involve sending and receiving data over HTTP, there are subtle differences that can encourage the choice between ond message type and another.
Raghavan Muthu
Ranch Hand
Joined: Apr 20, 2006
Posts: 3057
posted
Wow.. That's where the experience speaks. Thank you David for providing the extra-but-required-to-know the important information!