my dog learned polymorphism*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Stateful Session Beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Stateful Session Beans" Watch "Stateful Session Beans" New topic
Author

Stateful Session Beans

Dhananjeyun Rajendra
Greenhorn

Joined: Apr 29, 2005
Posts: 14
Hi,

Referring to Qn.8 of mock exam #3 from JavaQueries.com (same as Qn.104 at http://www.geocities.com/subra_73/SCEA_Practice_Questions.htm), which is also reproduced below, I'm wondering why servlets should be used instead of stateful session beans. Aren't the latter better to address the requirements? Moreover, if servlets can be used this way, then what is the point in having stateful session beans? Or is this one of those problematic questions?

--- Start ---
You are developing an online shopping store for an art gallery. The company aims to bring fine art to the masses and expects a huge volume of traffic through the site. The site allows customers to pay for goods and arrange delivery methods using credit cards. You have read through the requirements and have a rough design in your head. Which of the following is the most appropriate rough design for this site?

AHave an Entity Bean to represent the customer. Use a Servlet to manage the users session and use BMT to manage the transactions.
BHave an Entity Bean to represent the customer. Use a Stateful Session Bean to manage the users session and use BMT to manage the transactions.
CHave an Entity Bean to represent the customer. Use a Servlet to manage the users session and use CMT to manage the transactions.
DHave an Entity Bean to represent the customer. Use a Stateful Session Bean to manage the users session and use CMT to manage the transactions.

Choice C is correct.

The key to this question is the choice of Transactions: BMT or CMT. There is no need to control transactions at a fine level of granularity and Entity Beans cannot take part in BMT. Hence CMT may be a better choice. The Servlet is a more appropriate choice for handling the users session however you would still need another Stateful Session Bean for the business logic of the application.
--- End ---

Thanks in advance,
Dhanan.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
When using SFSBs you should always seek to keep the lifetime of the bean at a minimum - that's how you keep them scalable - scalability is adversely impacted the longer the beans are alive. Ideally you should create the SFSB at the beginning of a transaction, do your multiple method calls and discard it after the transaction is complete.
If an HttpSession is available, use it as a long lived (session) user data store - it's also more easily migrated from one server within a cluster to another.
See Stateful Session EJBs: Beasts of Burden to understand the situations were SFSBs are of some use.
[ November 14, 2005: Message edited by: Peer Reynders ]
Dhananjeyun Rajendra
Greenhorn

Joined: Apr 29, 2005
Posts: 14
Hi Peer,

Thanks for the reply and link.

Regards,
Dhanan.
 
 
subject: Stateful Session Beans
 
Similar Threads
Part I mock
Servlet or Stateful Session bean ?
Manage session state in Servlet in huge volume traffic site???
Found this Question in the Mock exam. Can anybody tell/explain what the choice is...
doubt in a mock exam q/a.