Home > Documentation > Developing > Tutorials > Developing EJB applications > Stateful Session Bean |
This application will take you through the basics of Stateful Session Bean. This application will demonstrate how annotations like @Stateful, @Resource, @PostConstruct, @PreDestroy, @PrePassivate, @PostActivate, @Remove are used in an EJB3 application.
Basically a Stateful Session EJB is used whenever there is a requirement to maintain a session. The example is a user registration process wherein the registration process is a two step process. First page prompts to enter your personal credentials and second page prompts to enter your billing and credit card information. The session is maintained till the user has filled up both the jsp pages. Later the complete information is populated on to a database. The application has a Controller servlet which routes the call received from the jsp client to the Bean class, setter methods and jsp pages.
To run this tutorial, as a minimum you will be required to have installed the following prerequisite software.
Details on installing eclipse are provided in the Development environment section.
This tutorial is organized in the following sections:
This section is organized in the following parts:
PersonalInfo.java
.
BillingInfo.java
and add the following code.
PersonalInfo.java
and BillingInfo.java
are classes for setting and getting the user information.Resolve the errors as follows.
<GERONIMO_HOME>/repository/org/apache/geronimo/specs/geronimo-ejb_3.0_spec/1.0.1
and select geronimo-ejb_3.0_spec-1.0.1.jar. Select Open.geronimo-annotation_1.0_spec-1.1.1.jar
.Let us walk through the EJB bean class code.
userinfo.sql
script. Select Run Sql.<GERONIMO_HOME>\repository\org\apache\geronimo\specs\geronimo-servlet_2.5_spec\1.1.2
and select geronimo-servlet_2.5_spec-1.1.2.jar and Select Open.Controller.java
servlet.
PersonalInfo.jsp
and Select Next.PersonalInfo.jsp
.
BillingInfo.jsp
and add the following code.Let's walk through the servlet and jsp code. First through Controller servlet code.
The above code is different from the original one in the sense that we have added another <servlet> for Controller1 which is mapped to the same servlet class. Similarly adding a <servlet-mapping> element for the Controller1 servlet. This feature is basically mapping of more than one servlet with same servlet class. This helps in routing each call from jsp in the Controller servlet.
Bookmark this on Delicious Digg this | Privacy Policy - Copyright © 2003-2013, The Apache Software Foundation, Licensed under ASL 2.0. |