• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling doGet() from doPost()

 
Jeremy Medford
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if this has already been discussed...

In Servlets, why would you want to call doGet() from your doPost() method as I see some examples doing?

 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually, it's lazy design. Someone didn't want to decide in advance whether the page should use GET or POST, or possibly just didn't understand the difference. I've done that myself too. In the past, when I didn't understand HTTP properly. Now I don't do it.

It's also possible that there are old tutorials on the web which do that too. That's quite likely why I decided to do it. All kinds of things are done in the early days of a technology which later we realize were not so good, and that could be one of those things. Then people find these tutorials (for some reason it seems to be easier to find old tutorials than new ones) and propagate the meme.

I suppose there might be designs where there exist pages which send GET requests to the servlet and also other pages which send POST requests to the same servlet. And if the system was legacy enough, it might be hard to track them all down and standardize the usage, so you'd use this approach to compensate for that.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50171
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to servlets forum
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic