views:

25

answers:

1

Hello, first of all sorry for my English is not my native language. I have a web form input field and a servlet (Clustered Weblogic AS) which receives the contents of this input. I would like to limit the attempts given the same value without using rdbms or plain text file, eg

// Getting value of form
String input = request.getParameter ("input");

// Attempts object saves the previously set values
if (attempts.check (input)> 3) (
   throw new Exception ();
Else ()
   attempts.setValue (input);
)

And I do not decide which is the most efficient way of doing it without using db or plain file.

  • Java Cache System
  • Static Variable

Another way?

A: 

caching and saving in a static variable will only last as long as the server is running. once you restart the server - your data is lost. out of the two - a static variable sounds faster. but if persistence is what you need - then you will have to write it to a file\db\nosql-db of some kind.

ozk