File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Idempotent.

 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

can't we change the state of an object if the method is get.Please somebody clarify.


Neeraj.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add more..

wats the best way to avoid users hitting submit twice when method is post ?

Neeraj.
 
Kai Witte
Ranch Hand
Posts: 356
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

Originally posted by Neeraj Vij:
can't we change the state of an object if the method is get.Please somebody clarify.


we can, but for GETs we SHOULD not change anything on the server. It's really just "should". Technically we could implement doGet in a non-idempotent way.

Conan
[ September 30, 2004: Message edited by: Conan Elvitaro ]
 
Brian Percival
Ranch Hand
Posts: 163
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings from Hogwarts,

Don't know if this is what you asked for but just disable the submit button after one click (javascript)

Brian
 
Chengwei Lee
Ranch Hand
Posts: 884
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I agree with Brian that JavaScript can prevent users from double submission.

If I'm not mistaken, Struts also had this capability of detecting double submission. Read this somewhere on the Struts page.
 
Neeraj Vij
Ranch Hand
Posts: 315
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Don't know if this is what you asked for


I want to avoid side effects of post method, when the user clicks submit button twice.

rgds,
Neeraj.
 
Ramnathan Ravindran
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Neeraj,
To add to what Brian has said, Javascript can used to prevent the double submission by a user. Actually I have that script logic here in my web application. I did answer your second question.
For the first one, whatever be the case the GET method is idempotent. It is we who have to make sure we dont override the doGet() to be a non-idempotent. It is not a rule but it would be better if we adhere to the objective of the Http Methods.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic