Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

protection against 'crazy user'

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a web application that uses JBoss 7.1, MySQL, EJB3.1, JPA2.0 and JSP.

I have a table with users. The user can be deleted. When 'Delete' link is clicked - the request goes as follows: -> servlet -> ejb ->persistence manager -> send redirect to jsp.
Everything works fine but it takes a second to present final jsp. The user can hit 'Delete' link a couple of times on the same record and the result is:

javax.ejb.EJBException: java.lang.IllegalArgumentException: attempt to create delete event with null entity

Is there anything that can prevent such situations? Is it a common problem?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two approaches you can use (using both is probably best)
1) Use JavaScript to submit preventing the form again while waiting for a reply. (or use a token to prevent duplicate submits)
2) Add a null check so it fails quieter. If it has already been deleted, mission accomplished. No need to error.

And yes, it is common. Especially if the website is slow or the user has low bandwidth.
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

I have realized that 'crazy user syndrome' is very usual, even in different situation. Let's say that we have two users and they both click 'Delete' button at the same time. It is something similar to multiple clicks performed by the same user. Null checking has solved the problem.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lucas Smith wrote:
I have realized that 'crazy user syndrome' is very usual, even in different situation. Let's say that we have two users and they both click 'Delete' button at the same time. It is something similar to multiple clicks performed by the same user. Null checking has solved the problem.


To be blunt, this should not be usual at all -- what you call "crazy user syndrome", I call good QA behavior. Clicking stuff in patterns not expected is the job of QA -- and if any QA person can't catch a delete twice issue, he/she is not doing their job.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic