• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reloading a Servlet

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have this slight issue. I am using AJAX to get the value of a variable from my servlet, this variable is an integer. The program works great. But I want a new servlet instance to be reloaded each time I refresh my jsp page. For instance, when the program runs, the value of an integer, say x, starts from 0 and increments to maybe 3 which is supposed to be the maximum value for x. My idea is that if the user uses the browser refresh button, it will uses a totally new servlet instance and remove the old one. So that If I reload the page and try to retrieve the value of x, the value returned will be zero and not 3. ANy ideas?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34072
333
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Igwe,
I don't understand what you are trying to do. User information is typically in the session, not the servlet. I can't imagine why it would matter which servlet instance a user gets. Maybe you could explain the goal of what you are trying to accomplish?
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Restarting with a new clean slate on every request - you have to abandon this idea when working with Servlets.

I came to Servlets from the CGI side - i know this feeling when you run into the traps of multithreading.

But it simply isn't the way things are done with Servlets.

You would have to pay such a high performance penalty that it isn't worth the pain.
I think you might even succeed in fiddling your configuration to reload on each request. At least i suppose you could do that - never tried.

But that's a bit like fixing wallpaper with nails. It works - admitted, but... well :-)

You have to dig your teeth in the Servlet issues multithreading, variable scope and clean design.

Sorry,

J.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic