File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Reloading a Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Reloading a Servlet" Watch "Reloading a Servlet" New topic
Author

Reloading a Servlet

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

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?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reloading a Servlet