Accessing a JavaBean
87
To examine the JavaBean code:
•
Open the file
TripBean.java
located in jrun_root/servers/tutorial/compass-ear/
compass-war/WEB-INF/classes/compass and look at the following Java code:
−
Public class
TripBean
with several private fields declared
−
Public accessor (get) methods for all of the private fields declared
−
Public mutator (set) method for the id fields, as follows:
public void setTripId(int tripId) {
this.tripId=tripId;
retrieve(tripId);
}
−
Public
retrieve
method, which accesses the database and retrieves trip detail for
the passed tripID:
public void retrieve (int id)
The next procedure reuses
TripBean
Java code and presents the retrieved data in a
different format.
To use the same JavaBean in a different way:
1 In the Compass Adventures home page, click the name of a trip.
The trip detail page appears:
2 In the trip detail page, click the Book Trip button.
The reservation page appears, and references the selected tripID in the URL.
3 Look at the code in
reservation.jsp
located in jrun_root/servers/tutorial/compass-ear/
compass-war.
A JSP
include
action inserts the file tripsummary.jsp:
<jsp:include page="tripsummary.jsp" flush="true"/>
Summary of Contents for 38000382 - Macromedia JRun - Mac
Page 1: ...Getting Started with JRun...
Page 16: ......
Page 68: ...54 Chapter 5 Introduction to EJB...
Page 82: ......
Page 110: ...96 Lesson 3 EJB Tutorial...
Page 128: ...114 Lesson 4 Web Services Tutorial...
Page 132: ...118 Index...