• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Using get() and post() together

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can i use get() and post() together so that the mechanism results in using get() for idempotent requests and post() for nonidempotent requests??
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know you can have doGet() call doPost() and vice-versa. Not sure what you mean by indempotent and nonidempotent requests.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The GET operation is also expected to be idempotent, meaning that it can safely be repeated. This is not quite the same as being safe, but in some common examples the requirements have the same result. For example, repeating queries is both safe and idempotent (unless payment is required!), but buying something or modifying data is neither safe nor idempotent.
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya, u can use doGet and doPost() methods together.
The service method calls the appropriate method based when the request method was get or post.
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how does doget() call dopost() ??
what is the advantage of that??
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I teach Java in a technical post-secondary school. We use a doPost that calls a doGet mostly for teaching purposes - that way, the students can use doGet and therefore, see the name/value pairs being passed to the server, and then, when they are ready for "production release", simply change their method to post. The doPost has one line of code in it - which calls the doGet and passes the appropriate request & response objects. Seeing the name/value pairs makes it easier for the beginning students to see what their program bugs might be.
I recommend it to them as a development tool, but tell them that they would normally change it to a post before installing the program.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I love University students, they use big words.

http://www.dictionary.com/search?q=idempotent
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by manas ahlaad:
how does doget() call dopost() ??
what is the advantage of that??


public void doGet( HttpServletRequest request,
HttpServletResponse response )
{
doPost( request, response );
}
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I use Forte in my projects and here's a skeleton servlet code that Forte generates when you create a new servlet:

I guess you notice that the method processRequest() is being called by both doGet() and doPost().
Ex Animo Java!
-- Val
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic