I'm a newbie and I have a question about Tomcat and instances.
I read some time ago that when a user do a request, the container give an instance of the web aplication to the user, translate jsp code to servlet code, and show to the user the html, then each user of the aplication will have an instance of each class (that the jsp code needs) in every request.
My question is there is a way to have a single instance (for example Users.class) shared by application users? Then if a user change something of that class, all users see that change.
Thanks in advance.
[ June 17, 2006: Message edited by: Jordi Monn� ] [ June 17, 2006: Message edited by: Jordi Monn� ]
Author and all-around good cowpoke
Joined: Mar 22, 2000
This is really a general servlets question - Tomcat and all the other servlet containers are supposed to implement the servlet API which is very strict about this. You can download a PDF file of the servlet API from this Sun site. Anyway - you need to adjust your view of how servlets work. Typically there is only one instance of a servlet -each user request is parsed into a request object and the appropriate service (GET, POST, etc) is called with that request. Each request is processed in its own Thread - managed by the container. The servlet container also creates a response object for the request. You can manipulate which objects are shared in the various scopes - including having one object shared by all users of an application. This is all covered in the API. Bill