"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Jk Robbins wrote:He tells me that all I can store in context is a static value
I could maybe create a timer class as a singleton
What do you think about the issue of having the servlet run the query every 2 or 3 minutes? Just put the servlet in a loop, or is there a better way to do that?
Jk Robbins wrote:He tells me that all I can store in context is a static value
Bear Bibeault wrote:Huh? You can store anything you want.
Jk Robbins wrote:I could maybe create a timer class as a singleton
Bear Bibeault wrote:Resist the urge to over-engineer. Why bother with a singleton? Just create one instance and store it in the app context. Over-complicating things is a recipe for future disaster,
Jk Robbins wrote:What do you think about the issue of having the servlet run the query every 2 or 3 minutes? Just put the servlet in a loop, or is there a better way to do that?
Bear Bibeault wrote:I think that way lies madness and death. Servlets must return a response. Putting a servlet into a loop is akin to jabbing yourself in the eyes with a screwdriver. Don't even go there.
If you need something running in the background, do it in its own thread,
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
Jk Robbins wrote:
Jk Robbins wrote:I suppose I can just have the servlet check to see if it already exists and if so, skip instantiating a new one?
Why have the servlet do anything at all? Establish one instance in app context in a context listener at app startup time and then you don't ever need to worry about whether it exists or not.
That's also a good place to start off a worker thread if need be.
Bear Bibeault wrote:
Jk Robbins wrote:I suppose I can just have the servlet check to see if it already exists and if so, skip instantiating a new one?
Why have the servlet do anything at all? Establish one instance in app context in a context listener at app startup time and then you don't ever need to worry about whether it exists or not.
That's also a good place to start off a worker thread if need be.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson