• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Doubt about another mock exam question

 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question1

You are designing an online cinema ticket booking application. At the moment you plan to have a controller to maintain user sessions, a customer component to hold personal details, a credit card validation component, a set of GUI screens and a cinema component with details of all movies and seating capacities. What should be used for each component?

A The controller should be a Stateful Session bean. The customer should be a Stateful Session bean. The cinema component should be a Stateful Session bean. The credit card validation component should be an Entity bean.
B The controller should be a Servlet. The customer should be a Stateful Session bean. The cinema component should be a Stateful Session bean. The credit card validation component should be an Entity bean.
C The controller should be a Stateful Session bean. The customer should be a Servlet. The cinema component should be a Stateful Session bean. The credit card validation component should be a Stateful Session bean.
D The controller should be a Servlet. The customer should be a Servlet. The cinema component should be a Stateful Session bean. The credit card validation component should be a Stateful Session bean.
E The controller should be a Stateful Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.
F The controller should be a Servlet. The cinema component should be a Stateful Session bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.
G The controller should be a Stateful Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.
H The controller should be a Servlet. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.
I Make the GUI using JSP pages
J Make the GUI an applet

Correct optionsare H and I.

According me Correct options should be E And I

My doubt is In above case how will i decide between servlets and statefull session beans for controller.

Please help
Thanks
 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gowher Naik:

E The controller should be a Stateful Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.

H The controller should be a Servlet. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.

My doubt is In above case how will i decide between servlets and statefull session beans for controller.



A short answer: Ask yourself the question, "Do I need the functionality of a shopping cart?" If yes, you can use a stateful session bean. Here, you don't.

Also: You will need a Servlet to act as a Controller for the JSP-pages. You cannot have JSP talking directly to a Stateful SB.

The idea here is obviously exposing the Entity beans to the Servlet. This is not to be recommended in Real Life.

For an application like this, I would use a stateless session bean, and never ever under any circumstances expose entity beans to anything but a session bean, if even that. The very idea of exposing entity beans (the EIS Integration tier) to the servlet (the Web tier) is bad, bad, bad.

Sorry, I'm ranting...

A better answer would be
K The controller should be a Servlet and a Stateless Session bean. The customer should be an Entity bean. The cinema component should be an Entity bean. The credit card validation component should be a Stateless Session bean.
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the previous answer is perfect... I want to include if you have a stateful you will need to put the remote object in an session variable, in order to get it and do the next step, but the JSPs are not the best components to have code like Remote object creation (or local) and execute, etc. you will have more business code in your JSP than you should.

If you are asked to control your application flow you will choose a Servlet because it's part of the MVC components, the Stateful are components to be used as business layer (or at least as business front), it should not drive your application flow, or control your screens (that's a controller responsibility).
 
Fire me boy! Cool, soothing, shameless self promotion:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic