• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reloading a Servlet

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic