File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes session in servers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "session in servers" Watch "session in servers" New topic

session in servers

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 580
A JEE application(contain many java objects) deployed in server.If several users access the application then server create session for each user, then all objects exist in the application available in each session. I explain as follow

For an example,

To display a value from database, application needs 4 java objects to display the value at browser. All objects are not singleton.

If 10 user access the application for the same functionality then server do follow the below listed sequence

1)create 10 sessions
2)every session has the new instance of 4 java objects
3)In session -1,if a user change the property of an object it never reflect in the property of the same object in session-2


1) Create 10 sessions
2) Server creates 10 threads of 4 objects and assign each thread to each session.
3) In session -1,if a user change the property of an object it never reflect in the property of the same object in session-2
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

Hi Jacob,

Is this a question from a mock exam? In that case you need to QuoteYourSources.

In answer to your question my understanding is that it is the first case.

Hope that helps!

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

I think the question is very vague.
It totally depends on your application.
If for each server request you create a new instance(via the new operator), you will get different objects for each thread.
On the other hand, if there is a class that creates objects for you (like a factory) and it caches instances, then it may be so that two sessions share the same instance.

The application server will not do any magic for you. It will just invoke your request in a thread and rest is upto you to manage.

apigee, a better way to API!
I agree. Here's the link:
subject: session in servers
jQuery in Action, 3rd edition