• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

DoGet() is must?.

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Servlet,DoGet() is must?.What is the Reason?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In Servlet,DoGet() is must?.What is the Reason?


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.
 
Ranch Hand
Posts: 142
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But some time
doPost()
{doGet()}
Calling like this?.What is the reason for that?
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we want to provide both the services, we generally use like the above .
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf, don't let me half-answer a question

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.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow.. That's where the experience speaks. Thank you David for providing the extra-but-required-to-know the important information!

Thanks Ulf for triggering David!
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!