miko said:
I wrote simple servlet and now I'm trying to access it from two different clients .
client a - open servlet , click on button (so the servlet send new page)
client b - open servlet - get the new page (and not the "welcome" page) .
I tried to check the cache parameter , but it doesn't use cache .
So the behavior described above is what you're getting, but not what you
want? Then you are storing request- or session-specific information in
the servlet or in the application context. Most likely the former --
look for mutable member variables and class variables in your servlet
class and eliminate them. (Once you understand better how the sevlet
API works you may find appropriate uses for such, but they are pretty
much never appropriate in a "simple" servlet.) Use local variables and
pass them to any helper methods that have need of them rather than
storing data in the servlet.
You must always keep in mind that at any one time there is only one
instance of your servlet class running in the servlet container, and it
will typically service many requests before being taken out of service.
The container may use the same one instance for the entire lifetime
of your application. Servlets should be thread-safe because the
container may process multiple requests through one instance
simultaneously. As a hack, a servlet that is not thread-safe can
implement SingleThreadedModel to force requests through it to be
serialized, but even then (and either way) you have to make sure that
one request doesn't change the state of the servlet or application in
any way that will inappropriately affect other requests from the same or
another client.
John Bollinger
(e-mail address removed)