Working with Entity bean using JPA">
Magazine
 
Working with Entity bean using JPA

<%
try {
s1 = request.getParameter(“t1”);
s2 = request.getParameter(“aut”);
s3 = request.getParameter(“price”);
if ( s1 != null && s2 != null && s3 !=
null) {
Double price= new Double(s3);
bci.addBook(s1, s2, price.doubleValue());
System.out.println(“Record added:”);
%>
<p>
<b>Record added</b>
<p>
<%
}
list=bci.getAllBooks();
for (Iterator iter = list.iterator();
iter.hasNext();){
BookBank element =
(BookBank)iter.next();
%>
<br>
<p>Book ID: <b><%= element.getId()
%></b></p>
<p>Title: <b><%= element.getTitle()
%></b></p>
<p>Author: <b><%=
element.getAuthor() %></b></p>
<p>Price: <b><%= element.getPrice() %>
</b></p>
<%
}
}// end of try
catch (Exception e) {
e.printStackTrace ();
}
%>

The source code for the “index.jsp” is given below that will actual call the client-design form.

<%@page language=”java” %>
<html>
<head>
<title>Ejb3 JPA Tutorial</title>
</head>
<body bgcolor=”#FFFFCC”>
<p align=”center”><font size=”6"
color=”#800000"><b>Welcome to <br>
Ejb3-Jboss 4.2.0 Tutorial</b></font>
Click <a href=”ejb3/form.jsp”>Book Catalog
Example</a> to execute Library<br></p>
</body>
</html>

 

V. Deploy book application on the Application Server

Before deploying this application, make sure for that you have the following tools on your system.

• JDK 1.5 or Higher
• apache-ant-1.7.0
• JBoss 4.2.0

Do the following steps to deploy the calculator application:

(i) Make a directory structure. You can Click here to extract the readymade directory structure according to this tutorial.

(ii) Create the essential deployment descriptor .xml files.

build.xml

<?xml version=”1.0"?>
<project name=”Jboss Tutorials” default=”all”
basedir=”.”>
<target name=”init”>
<!— Define —>
<property name=”dirs.base”
value=”${basedir}”/>
<property name=”classdir”
value=”${dirs.base}/build/classes”/>
<property name=”src”
value=”${dirs.base}/src”/>
<property name=”web”
value=”${dirs.base}/web”/>
<property
name=”deploymentdescription”
value=”${dirs.base}/deploymentdescriptors”/
>
<property name=”warFile”
value=”book.war”/>
<property name=”earFile”
value=”book.ear”/>
<property name=”jarFile”
value=”book.jar”/>
<property name=”earDir”
value=”${dirs.base}/build/ear”/>

Feb  2008 | Java Jazz Up | 12
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,

Download PDF