• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maintaing everthing in Session Object

 
Bunty Paul
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 425
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13044
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic