Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 CS 483 Enterprise and Web Application Programming Week 6 Session Beans JSP Tutorial.

Similar presentations


Presentation on theme: "1 CS 483 Enterprise and Web Application Programming Week 6 Session Beans JSP Tutorial."— Presentation transcript:

1 1 CS 483 Enterprise and Web Application Programming Week 6 Session Beans JSP Tutorial

2 2 Session Beans (SB) Session Beans are a set of objects that implement the business logic of an application SBs tend to be responsible for a group of related functionality Not using persistent storage

3 3 Types of Session Beans Stateless Beans Do not care declare any instance (class-level) variables so that the methods contained within can only act upon any local parameters There is no way to maintain state across method calls Provide excellent scalability because EJB container does not have to keep track of their state across method calls Ex: Provide some generic service to clients like signing in or a Catalog bean – browsing different products and categories – generic to any client

4 4 Types of Session Beans Stateful Beans Can hold client state across method invocations – contains conversational state on behalf of the client Possible with the use of instance variables declared in the class definition of session bean Client will then set the values for these variables and then use these values in other method calls Storing the state of an EJB is very resource intensive – therefore does not scale as well as stateless beans Ex: Shopping Cart for an online store

5 5 Decisions, Decisions... How do you decide whether a given enterprise bean should be a session or entity bean? Session beans are great at implementing business logic, processes, and workflow Ex: StockTrader bean with buy() and sell() methods Entity bean are the persistence data objects of the EJB application Ex: getPrice() and setPrice() StockTrader SB could call the above methods in the EB

6 6 Decisions, Decisions... It is good practice to have the client only interface with session beans and the session beans interface with the entity beans for these reasons: Single point of entry for the client Calling entity beans directly tends to push the business logic into the UI logic UI doesn’t have to be as dependent upon changes to the entity beans – session beans shield the UI from these changes There are usually many more entity beans so restricting client access to session beans conserves server and network resources considerably

7 7 Anatomy of a Session Bean UI calls the methods of the session bean as it requires the functionality they provide. Session beans can call other session beans and entity beans

8

9 9 Java Server Pages Overview

10 10 JSP Resources Sun’s website http://java.sun.com/products/jsp/docs.html J2EE 1.4 Tutorial Search the site for JSP – there are whitepapers, articles, blueprints (best practices), etc. Free Online Books http://www.coreservlets.com Free Online books – they are the previous rev but most of the information is relevant and the author indicates where it is not. Register with email address Others: http://www.jsptut.com http://www.theserverside.com/articles/index.tss

11 11 Last Assignment – Due Week 8 before Final Exam Create one more entity bean that relates to your topic Create a session bean that works with the two entity beans Perform transaction control Using XHTML, create a Web page that will ask the user for some information, retrieve the information from the database, and display back to the user Use JSP as the middle tier between the client and server beans

12 JSP Model 1: Must do this as a minimum JSP Model 2: Big Fat Bonus!


Download ppt "1 CS 483 Enterprise and Web Application Programming Week 6 Session Beans JSP Tutorial."

Similar presentations


Ads by Google