• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question on EJB -- pls. explain me the difference.

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It has been confusing. As everytime when i see a question on the use of servlet Vs. Stateful session bean.

For eg in the following example my preference is to use Stateful session bean to manage users session over Servlet. As this is a classic shopping cart ex. let me know as the mock test had to suggest serlvet usage here.

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.
 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by veena madhukar:
It has been confusing. As everytime when i see a question on the use of servlet Vs. Stateful session bean.

For eg in the following example my preference is to use Stateful session bean to manage users session over Servlet. As this is a classic shopping cart ex. let me know as the mock test had to suggest serlvet usage here.

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.



Veena,

The question about which type of technology use for maintain users session state depends of the non functional requirements of your application.

In yours example, you could see that the application must be used for a huge volume of traffic. This means that you have to implement 'SCALABILITY'.

Another point is, The site allows customers to pay for goods and arrange delivery methods using credit cards. This means that you must ensure 'TRANSACTIONAL BEHAVIOR'.

Those two points refers to the use of enterprise beans, since they can provide this benefits for the application. EJB�s by specification ensures scalability and transactional behavior.

Web Containers can offers transactions using JTA, but scalability is a specific vendor feature. And of course, even having open-source web containers as tomcat, jonas, jboss, geronimo that providers those features, you can�t design an solutions that depends of an specific product to works. An architect must ensure that your solution is vendor independent. So, EJB�s (SFSB) are very recommended for this situation.

If you do not need any of this non functional requirements to maintain users sessin state, you can easly use the HttpSession object and maintain those references in the web tier. You can even, use the both approachs together.

Use the HttpSession is easier to the programmer, since there is no special technology to use, just call the HttpSession.setAttribute() method. But, the HttpSession is dangerous in an heterogeneous environment. The HttpSession clustering is much more expensive rather SFSB clustering, because, in the SFSB cluster, only the state must be moved between JVM�s. In the HttpSession cluster, the entire HashMap (collection of references) must be copied between JVM�s, and you need to ensure that every object maintained in the HttpSession, implements the java.io.Serializable interface.

You see, the 'simpliest' approach offered by the HttpSession defines much more work to ensure scalability, over the simpliest and ensured stateful session beans.

I hope have helped you !
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by veena madhukar:
... my preference is to use Stateful session bean to manage users session over Servlet. As this is a classic shopping cart ex....



Please take some time and read Stateful Session EJBs: Beasts of Burden

Also see the related topic servlet vs stateful session bean.
[ March 14, 2006: Message edited by: Peer Reynders ]
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for posting question & your answers.
What I have understood is that SFSB provides scalability because of activation/passivation feature; that allow more user to use the service compare to HttpSession which doesnot provide alternative in case max limit of user is matched (but some vedor provides activation/passivaion of HttpSession too but since its not part of J2EE specification yet, application would be specified to the same app/web server). So SFSB is prefered comare to HttpSession.

For eg in the following example my preference is to use Stateful session bean to manage users session over Servlet. As this is a classic shopping cart ex. let me know as the mock test had to suggest serlvet usage here.


Is there any reason given in mock test with answer; and in which mock test you find this answer; can u share this pls.
regards.
[ March 15, 2006: Message edited by: sanjeev mehra ]
 
veena madhukar
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the questions in the mock test http://www.javaqueries.com/scea.do They don't give reasons for their reasons. i wish they had given some reasons.
 
Always! Wait. Never. Shut up. Look at this tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic