• Post Reply Bookmark Topic Watch Topic
  • New Topic

HttpSession vs Stateful Session EJB

 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is a very good question and I'd like to see what others have to say. At work, our tech supervisor wants us to use the HttpSession object as least as possible and use the Request object (via the set and getAttribute method pair) when dealing with objects that last only one request.
He says that what we should do is keep the session info in a stateful session bean and have the stub or reference to that bean, in the HttpSession.
Something to do when you have a cluster of servers working together... If the HttpSession is loaded with a lot of data, it may affect performance.
However, in small installations with maybe one server only, it may not make a difference...
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In using Netscape Application Server, it seems that the session object does has a limit of 4K, if the session objects has stored more than 4K of stuff, the performance will degrade greatly. However this might not be true for other application servers so you might want to check with the vendor to see if they have a prefered size for the session object.
In general, the stateful session beans does not only serves as a "shopping cart" storage, it can also contains business logics and methods inside for other operations.
HHC
 
smercmu
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really depends on where you will be using the data. If the front end display / user interface displays the username, etc, then put the items in HttpSession. If they are being used by the model, put them in the EJB.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I strongly disagree. Stateful session beans are of the devil. Tony, do a search back a few weeks and you'll see a long discussion on this same subject.
Kyle
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should point out that Tony created this thread 4 years ago... and it was merely resurrected.
 
Augg Stine
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I srongly believe that maintaining session thru stateful session bean will be very much costly in terms of performance. instead we could use stateless session beans with http session implemented in servlets
rgds/ Augg
 
Xie Ruchang
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Augg,
You may wish to read this article by Gavin King and find out for yourself SFSBs are not bad after all. They have done some benchmarking on HttpSession versus SFSBs and I think it is good to let the results speak for themselves
Best Regards,
Frankie
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That article was very nearly meaningless. It was done on ONE application server, installed on ONE machine and in ONE configuration. He also didn't discuss the read/write ratio, or failover, which would need to be covered in a real test. It tells you nothing about how the two compare in real applications.
Kyle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!