File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Tomcat and instances Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat and instances" Watch "Tomcat and instances" New topic
Author

Tomcat and instances

Jordi Monn�
Greenhorn

Joined: Feb 28, 2006
Posts: 21
Hello,

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� ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat and instances