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 Maintaing everthing in Session Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Maintaing everthing in Session Object" Watch "Maintaing everthing in Session Object" New topic
Author

Maintaing everthing in Session Object

Bunty Paul
Greenhorn

Joined: Jun 26, 2006
Posts: 28
Hi,

I have many servlets which does many activities and i almost maintain every detail that i require in the session object. I heard that maintaining everthing in a sesson object will reduce the performance of the server. Is this true?. Is there any alternative or else can you please tell a better way of handling this part.

Thanks
Bunty Paul
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
Having everything in Session is sure kill for the application as the application will not be able to scale with number of users. In addition if you move to cluster environment then this will definitely bog your network resource as well. One approach is to

Lets say your web app has 4-5 submodules which do not need or atleast completely share the session attributes of other modules, then

- You can define one session container ( a bean object) for each of the submodules. This container acts like a wrapper and contains all other attributes needed for the particular module (which are not shared by other modules). So in our case we will have 4-5 root session container.

- You need to write a filter to intercept the incomming request. In the filter you need to decide if the session contains only the root session object (above) required for the current url. If session contains root objects of other module then you can remove them.

I perfer to use the container class for attributes of each submodule so that cleaning the session won't be painfull. However the downside of this approach is if you want to read any actual attribute of the module then you first need to retriever the container of the submodule and get the respective attribute.
[ August 02, 2006: Message edited by: Purushothaman Thambu ]
Bunty Paul
Greenhorn

Joined: Jun 26, 2006
Posts: 28
i came to understand that i need to store my modules info in a stateful session bean[session container]/client's session. Can you please tell me what is the difference between a ejb session and an http session.
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
I think I am not clear about the container. I meant just a java bean wrapper for each attribute of particular module in the webapp and didn't mean EJB Session Bean. EJB Session Bean and the Http Session are entirely different and EJB Session Bean are not related to the context we are discussing
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12671
    
    5
I heard that maintaining everthing in a sesson object will reduce the performance of the server. Is this true?.

Short answer: NO

Longer answer - it depends - this is another of the many preposterous generalizations that contaminate the servlet/jsp programming world.

The purpose of a session is to hold on to the unique data for a particular user's interactions with a web application. The servlet API provides for other mechanisms for holding resources specific to individual servlets, to web applications, and to entire servers.

Any more discussion of the use of sessions would require more information about your particular application.

Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maintaing everthing in Session Object
 
Similar Threads
HttpSession in bean
Top 10 Servlet/JSP misconceptions.
I have to remember all the existing classes?
Session Object
jsp:useBean conceptual problem