In this EJB-JPA tutorial, we will make changes to the web application files and create new html file for FundTransfer. Later we will learn the merge method of EntityManager.
1. Fund Transfer Html Form
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 |
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head> <body> <!-- Sample 5.01: Fund Transfer Form --> <FORM action="FundTransfer"> <h1>Fund Transfer</h1> From Account ID: <br> <input name="pidFrom" type="text" size="3" value=""><br> To Account ID: <br> <input name="pidTo" type="text" size="3" value=""><br> Amount: <br> <Input name="amount" type="text" size="5" value=""><br> <input name="Xfer" type="submit" value="Transfer"><br> </FORM> <h3> <a href="http://localhost:8080/EJBWeb/SavingsAcHomePage.html"> Home </a> </h3> </body> </html> |
2. SavingAc Home Page
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 |
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <title>Insert title here</title> </head> <body> <!-- Sample 4.04: Create Form for Account Creation --> <h2> <span style="color: #0000ff;">With This JPA-Entity Example you can perform the Follow Operations:</span> </h2> <table style="border-collapse: collapse; width: 100%; height: 159px;" border="0"> <tbody> <tr style="height: 53px;"> <td style="width: 50%; text-align: center; height: 53px;" colspan="2"> <h3 style="text-align: center;"> <a href="http://localhost:8080/EJBWeb/CreateAccount.html"> Create Savings Ac</a></h3> </td> </tr> <tr style="height: 53px;"> <td style="width: 50%; height: 53px;"> <h3 style="text-align: center;"> <a href="http://localhost:8080/EJBWeb/TransactAc.html">Deposit</a> </h3> </td> <td style="width: 50%; height: 53px;"> <h3 style="text-align: center;"> <a href="http://localhost:8080/EJBWeb/TransactAc.html">Withdraw</a> </h3> </td> </tr> <tr style="height: 53px;"> <td style="width: 50%; text-align: center; height: 53px;" colspan="2"> <h3 style="text-align: center;"> <a href="http://localhost:8080/EJBWeb/CloseAc.html"> Delete Savings Account</a></h3> </td> </tr> <!-- Sample 5.02: Add Transfer Fund Link --> <tr style="height: 53px;"> <td style="width: 50%; text-align: center; height: 53px;" colspan="2"> <h3 style="text-align: center;"> <a href="http://localhost:8080/EJBWeb/FundTransfer.html"> Transfer Funds</a></h3> </td> </tr> </tbody> </table> </body> </html> |
3. Jsp Response
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 73 74 |
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <% //Sample 4.16: Check the Response is for Create Account String Action = (String) request.getAttribute("Action"); if (Action.compareToIgnoreCase("Add") == 0) { %> <H3> Account Created</H3> <p> Account Id is: <%= request.getAttribute("NewAccountID") %> <% } %> <% //Sample 4.17: Check the Response is Deposit if (Action.compareToIgnoreCase("deposit") == 0) { %> <H3>Your Deposit amount is Credited.</H3> <p> New Account Balance is: <%= request.getAttribute("NewBalance") %> <% } %> <% //Sample 4.18: Check the Response is withdraw if (Action.compareToIgnoreCase("withdraw") == 0) { %> <H3>You withdrawn Money..</H3> <p> New Account Balance is: <%= request.getAttribute("NewBalance") %> <% } %> <% //Sample 4.19: Check the Response Account Close if (Action.compareToIgnoreCase("close") == 0) { String ret = (String) request.getAttribute("CloseVal"); if (ret.compareToIgnoreCase("True") == 0) { out.println("Account Removed"); } else { out.println("Account not found"); } } %> <% //Sample 5.03: Say Fund Transferred if (Action.compareToIgnoreCase("FundTransfer") == 0) { %> <H3>Fund Transferred!.</H3> <% } %> <h3><a href="http://localhost:8080/EJBWeb/SavingsAcHomePage.html"> Home</a></h3> </body> </html> |
Categories: JavaEE-EJB-Tube