Creating a Loan Processing Composite Application
Last Updated: 14 November 2006
Contributed by Sherry Barkodar, maintained by Alyona Stashkova
This tutorial provides an overview of a simple Loan Requestor
composite application and illustrates deploying, executing, and testing
of a Composite Application using the NetBeans Enterprise Pack 5.5
bundle with all the necessary runtimes.
The Loan Requestor composite application satisfies the following business use case:
- The user applies for a loan by filling out a loan request,
including information such as personal identifying information, amount
of loan requested, and credit history.
- When the loan request is received, the personal information
supplied by the user is verified across an existing database, and
approval is granted or rejected based on the information and the amount
requested.
- After certain formalities are fulfilled, a report, in the form of
an approval letter, is generated and sent to the user, confirming the
approval of the loan.
- If the loan is rejected for some reason, then a report showing the reason for the rejection is generated and displayed.

Click to enlarge
Prerequisites
This tutorial assumes that you have some basic knowledge of, or
programming experience with, the Java language and platform and the
NetBeans IDE.
System Requirements
This tutorial assumes that your system meets the requirements specified in the System Requirements topic of the NetBeans Enterprise Pack 5.5 Release Notes.
Software Needed for the Tutorial
Before you begin, you must install the following software on your computer:
- NetBeans IDE 5.5 with NetBeans Enterprise Pack 5.5 (download)
- In order to complete the deployment steps in this tutorial, you
must have Sun Java System Application Server Platform Edition 9 Update
1. This Application Server is bundled with the NetBeans Enterprise Pack
5.5 download.
Contents
top
Configuring the Tutorial Environment
Before you can deploy your application, the Sun Java System
Application Server and JBI runtime must be configured correctly and
running.
To configure the tutorial environment:
- Click the Runtime tab to open the Runtime window.
- In the Runtime window, expand the Servers node.
- If the Servers node already contains a Sun Java System Application Server 9 node, then go to step 5.
- If the Servers node does not contain a Sun Java System Application Server 9 node, then do the following to add an application server:
- Right-click the Servers node and choose Add Server from the pop-up menu.
The Add Server Instance dialog box opens.
- In the Choose Server page, from the Server drop-down list, select Sun Java System Application Server.
- (Optional) In the Name field, accept the default value or type the name you want to use to identify the server in the IDE.
- Click Next.
The Platform Location Folder page opens.
- In the Platform Location field, use the Browse button to navigate to and select the Application Server installation location.
If you accepted the default values during the installation, the location is C:\Sun\Appserver.
- Select the Register Local Default Domain option.
- Click Next.
- Supply the user name and password for the domain's administrator.
If you accepted the default values during the installation, the user name is admin and the password is adminadmin.
- Click Finish.
- In the Runtime window, right-click the Sun Java System Application Server 9 node and choose Start.
If the Start option is not available, the server is already running and you can skip the next step.
- Wait until the following message appears in the Output window:
Application server startup complete.
When the server is running, the IDE displays a green arrow badge on the Sun Java System Application Server 9 node.

Click to enlarge
top
Creating the BPEL Project
In this section, you create a BPEL Module project called LoanRequestor.
To create the LoanRequestor project:
- From the IDE's main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the Service Oriented Architecture node.
- In the Projects list, select the BPEL Module node.
- Click Next.
- In the Project Name field, type LoanRequestor.
- (Optional) In the Project Location field, use the Browse button to
navigate to and select a different folder where the IDE will store the
project files.
- Click Finish.
The Projects window now contains a project node for a BPEL Module project called LoanRequestor.
top
Creating the XML Schema
In this section, you add a new XML schema file to your BPEL Module project and then add XML schema components to the schema.
To create LoanRequestor.xsd:
- In the Projects window, expand the LoanRequestor project node, then right-click the Process Files node and choose New > File/Folder.
The New File wizard opens.
- In the New File wizard, do the following:
- In the Choose File Type page, in the Categories list, select the XML node, then in the File Types list, select the XML Schema node and click Next.
- In the File Name field, type LoanRequestor.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.xsd. The Source Editor contains a tab for the XML schema file, LoanRequestor.xsd, with the Schema view open.
- In the Schema view, click the Design button to open the Design view of the XML schema editor.
To add complex types to the XML schema:
- In the Palette of the Design view, expand the XML Schema Components section and select the Complex Type icon.
If the Palette window is not visible, choose Window > Palette from the main menu.
- Drag your selection to the schema design area immediately below the Complex Types node.
The IDE adds a Complex Type node and the name of the complex type (newComplexType) is selected and ready for you to change.
- Type processApplication in the new node and press Enter.
The Design area now shows your new complex type, called processApplication.
- Repeat steps 1 to 3 and name another new complex type processApplicationResponse.
To add local elements to processApplication and processApplicationResponse:
- In the XML Components section of the Palette, select the Element icon and drag your selection onto the processApplication node in the schema design area.
The IDE adds an element node labeled newElement.
- If the Properties window is not visible, choose Window > Properties.
- In the Schema design area, select the newElement node.
- In the Properties window, select the value field of the Name property to make it editable and type socialSecurityNumber.
- In the Properties window, set the value field of the Nillable property to True.
- In the Properties window, in the Definition property, click the ellipsis button.
The Definition dialog box opens.
- In the list, expand the Built-in Types node and select the string node.
- Click OK.
- Repeat steps 1 to 8 to add the following elements:
Name |
Nillable |
Definition |
applicantName |
True |
string |
applicantAddress |
True |
string |
applicantEmailAddress |
True |
string |
applicantAge |
True |
int |
applicantGender |
True |
string |
annualSalary |
True |
double |
amountRequested |
True |
double |
- In the XML Components section of the Palette, select the Element icon and drag your selection onto the processApplicationResponse node in the schema design area.
The IDE adds an element node labeled newElement.
- In the schema design area, select the newElement node.
- In the Properties window, select the value field of the Name property to make it editable and type return.
- In the Properties window, in the Definition property, click the ellipsis button.
The Definition dialog box opens.
- In the list, expand the Built-in Types node and select the string node.
- Click OK.
To add global elements:
- In the XML Components section of the Palette, select the Element
icon and drag your selection to the Design area, immediately below the
Elements node.
The IDE adds a newElement
component below the Elements nodes in the schema design area.
- In the Schema design area of the Design view, select the newElement node.
- In the Properties window, select the value field of the Name property to make it editable and type processApplication.
- In the Properties window, in the Definition property, click the ellipsis button.
The Element's definition - Definition dialog box opens.
- In the list of types, expand the Complex Types node and select the processApplication complex type node.
- Click OK.
- Repeat steps 1 to 6 to add the following element:
Name |
Complex Types |
processApplicationResponse |
processApplicationResponse |
- To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.
top
Creating the WSDL Document
In this section, you add a WSDL file to your BPEL Module project and then configure the components of the WSDL Document.
To create LoanRequestor.wsdl:
- In the Projects window, expand the LoanRequestor project node, then right-click the Process Files node and choose New > WSDL Document.
The New WSDL Document wizard opens.
- In the Name and Location page, do the following:
- In the File Name field, type LoanRequestor.
- Select the Import XML Schema File(s) checkbox.
- In the XML Schema(s) field, click the Browse button.
The Select Schemas dialog box opens. This dialog box shows the XML schemas in your project.
- Select src/LoanRequestor.xsd and click OK.
- Click Next.
The Abstract Configuration page opens.
- In the Input area of the Abstract Configuration page do the following:
- In the Message Part Name column, double-click the default value to make the field editable.
- Type requestLoanMessage and press Enter.
- In the Element Or Type column, click the ellipsis button.
The Select Element Or Type dialog box opens.
- Expand the LoanRequestor node, the src/LoanRequestor.xsd node, and the Elements node.
- Under the Elements node, select the processApplication node and click OK.
- In the Output area of the Abstract Configuration page do the following:
- In the Message Part Name column, double-click the default value to make the field editable.
- Type responsePart and press Enter.
- In the Element Or Type column, click the ellipsis button.
The Select Element or Type dialog box opens.
- Expand the LoanRequestor node, the src/LoanRequestor.xsd node, and the Elements node.
- Under the Elements node select processApplicationResponse and click OK.
- Click Next.
The Concrete Configuration page opens.
Note: When you perform the next step, the error message at the bottom of the page disappears.
- Under Binding Subtype, select the Document Literal option.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.wsdl. The Source Editor contains a tab for the WSDL file, LoanRequestor.wsdl, with the new WSDL view open.

Click to enlarge
top
Partner Services
The Loan Application communicates with its partner services via
their public interfaces. These interfaces are defined in
partner-specific WSDL files.
This tutorial includes a zipped J2EE project called LoanProcessor and instructions for creating the EJB from scratch in the Appendix. The LoanRequestor project contains a very basic EJB implementation of a partner service.
The partner web service must be deployed to the bundled Sun Java Application Server before you can test run the LoanRequestorCompositeApp.
This implementation is only meant to serve as a test harness for the Loan Service process.
To open the LoanProcessor project:
- In your file system, create a directory named LoanTut.
- Download the loanejb.zip file and extract it into the LoanTut directory.
- From the IDE's main menu, choose File > Open Project.
The Open Project wizard opens.
- Navigate to the LoanTut directory that you just created, select the LoanProcessor project, and click Open Project Folder.
A progress dialog box appears, and then the project appears in the Projects window.
To deploy the LoanProcessor project:
- Right-click the LoanProcessor and choose Deploy Project.
- Wait until the BUILD SUCCESSFUL message appears in the Output window.
- To verify that the LoanProcessor enterprise application is successfully deployed, switch to the Runtime window.
- Expand the Sun Java System Application Server node, the Applications node, and the EJB Modules node.
The LoanProcessor node must be added.
top
Creating the BPEL Process
To create LoanRequestor.bpel:
- In the Projects window, expand the LoanRequestor project node, right-click the Process Files node and select New > BPEL Process.
The new BPEL Process wizard opens.
- In the File Name field, type LoanRequestor.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.bpel.
The Source Editor contains a tab for the BPEL process, LoanRequestor.bpel, with the Design view of the BPEL Designer open.
To add partner links:
- In the Projects window, expand the LoanRequestor project node, then expand the Process Files node and select the LoanRequestor.wsdl node.
- Drag your selection (LoanRequestor.wsdl) from the Projects window to the Design view.
The Partnerlink1[Partner Link] - Property Editor opens.
- In the Name field, type BpelImplementation.
- Accept the defaults and click OK.
- In the Projects window, expand the LoanProcessor project node, then expand the Web Services node and select the LoanProcessor web service node.
- Drag your selection (LoanProcessor web service node) from the Projects window to the Design view.
The Partnerlink1[Partner Link] - Property Editor opens.
- In the Name field, type EjbImplementation.
- Accept the defaults and click OK.
- In the Projects window, under Process Files, the Partners folder is created.
- Expand the Partners node, this folder contains the LoanProcessor node that includes LoanProcessor.wsdl and LoanProcessorService_schema1.xsd files.
To add a Receive activity:
- In the Web Service section of the Palette, select the Receive icon
and drag your selection to the Design area between the Process Start
activity and the Empty activity.
The IDE provides you with visual clues to show you where you can drop the selection.
This action places a Receive activity called Receive1 in the Design view.
- Double-click the Receive1 activity.
The Receive1[Receive] Property Editor opens.
- Change the value in the Name field to ReceiveFromCustomer.
- From the Partner Link drop-down list, select BpelImplementation.
The IDE fills in the Operation field.
- Create a new input variable by doing the following:
- Click the Create button next to the Input Variable field.
The New Input Variable dialog box opens.
- Change the value in the Name field to requestLoanInput.
- Click OK.
- Click OK to close the Receive1 [Receive] - Property Editor.
The Receive activity is now labeled ReceiveFromCustomer in the Design view.
To add an Invoke activity:
- In the Web Service section of the Palette, select the Invoke icon
and drag your selection to the Design area after the Receive activity.
The IDE provides you with visual clues to show you where you can drop the selection.
This action places an Invoke activity called Invoke1 in the Design view.
- Double-click the Invoke1 activity.
The Invoke1[Invoke] - Property Editor opens.
- Change the value in the Name field to InvokeLoanProcessorEJB.
- From the Partner Link drop-down list, select EjbImplementation.
The IDE fills in the Operation field.
- Create a new input variable by doing the following:
- Click the Create button next to the Input Variable field.
The New Input Variable dialog box opens.
- Change the value in the Name field to processApplicationInput.
- Click OK.
- Create a new output variable by doing the following:
- Click the Create button next to the Output Variable field.
The New Output Variable dialog box opens.
- Change the value in the Name field to processApplicationOutput.
- Click OK.
- Click OK to close the Invoke1[Invoke] - Property Editor.
The Invoke activity is now labeled InvokeLoanProcessorEJB in the Design view.
To add a Reply activity:
- In the Web Service section of the Palette, select the Reply icon
and drag your selection to the Design area after the Invoke activity.
The IDE provides you with visual clues to show you where you can drop the selection.
This action places a Reply activity called Reply1 in the Design view.
- Double-click the Reply1 activity.
The Reply1 [Reply] - Property Editor opens.
- Change the value in the Name field to ReplyToCustomer.
- Set the Partner link to BpelImplementation.
- Create a new output variable by doing the following:
- Make sure the Normal Response option is selected.
- Click the Create button next to the Output Variable field.
The New Output Variable dialog box opens.
- Change the value in the Name field to requestLoanOutput.
- Click OK.
- Click OK to close the Reply1 [Reply] - Property Editor.
The Reply activity is now labeled ReplyToCustomer in the Design view.
To add the first Assign activity:
- In the Design area, select the Empty activity, right-click and choose Delete from the pop-up menu.
- In the Basic Activities section of the Palette, select the Assign icon and drag your selection to the Design area between the Receive activity and the Invoke activity.
The IDE provides you with visual clues to show you where you can drop the selection.
This action places an Assign activity called Assign1 in the Design view.
- Select the Assign1 activity.
- In the Assign1 [Assign] - Properties window, select the value field of the Name property to make it editable, type AssignReceiveToEJBInput, and click OK.
- If the BPEL Mapper window is not visible, choose Window > BPEL Mapper from the main menu.
- In the left pane of the BPEL Mapper, under Variables, expand the requestLoanInput and requestLoanMessage nodes.
socialSecurityNumber, applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, amountRequested appear under requestLoanMessage.
- In the right pane of the BPEL Mapper, under Variables, expand the processApplicationInput and Parameters nodes.
socialSecurityNumber, applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, amountRequested appear under parameters.
- Drag socialSecurityNumber from the left pane of the BPEL Mapper to the socialSecurityNumber node in the right pane of the BPEL Mapper.
- Repeat step 7 for the following variables:
applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, and amountRequested.
- To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.
To add the second Assign activity:
- In the Basic Activities section of the Palette, select the Assign icon and drag your selection to the Design area between the Invoke activity and the Reply activity.
This action places an Assign activity called Assign1 in the Design view.
- Select the Assign1 activity.
- In the Assign1 [Assign] - Properties window, select the value field of the Name property to edit it, type AssignEJBOutputToReply, and click OK.
- If the BPEL Mapper window is not visible, choose Window > BPEL Mapper from the main menu.
- In the left pane of the BPEL Mapper, under Variables, expand the processApplicationOutput and parameters nodes.
return appears under parameters.
- In the right pane of the BPEL Mapper, under Variables, expand the requestLoanOutput and responsePart nodes.
return appears under responsePart.
- Drag return from the left pane of the BPEL Mapper to the return node in the right pane of the BPEL Mapper.
- To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.

Click to enlarge
To Build the LoanRequestor BPEL Project:
- In the Projects window, right-click the LoanRequestor project node and choose Clean and Build Project.
- If the BUILD SUCCESSFUL message appears in the Output window, then the Build has succeeded.

Click to enlarge
top
Before you deploy the BPEL Module project, you must add the JBI
module to the deployment project. Deploying the project makes the
service assembly available to the application server, thus allowing its
service units to be run.
To create the Composite Application project and add the JBI module:
- From the IDE's main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the Service Oriented Architecture node.
- In the Projects list, select the Composite Application node.
- Click Next.
- In the Project Name field, type LoanRequestorCompositeApp.
- Click Finish.
The Projects window now contains a project node for a Composite Application project called LoanRequestorCompositeApp.
- In the Projects window, right-click the LoanRequestorCompositeApp project node and choose Add JBI Module from the pop-up menu.
The Select Project dialog box opens.
- Select the LoanRequestor project you created earlier in this tutorial and click Add Project JAR Files.
The Select Project dialog box closes.
- In the Projects window, expand the LoanRequestorCompositeApp project node and then expand the JBI Modules node.
Notice that a LoanRequestor.jar node has been added.
To deploy the Composite Application:
- Right-click the LoanRequestorCompositeApp project node and choose Deploy Project.
If the BUILD SUCCESSFUL message appears in the Output window, then the deployment has succeeded.

Click to enlarge
top
Testing the Composite Application
You can enhance the Composite Application project by adding test
cases, binding to the operation, supplying input, and then using the
Tester.
To test the LoanRequestorCompositeApp:
- In the Projects window, expand the LoanRequestorCompositApp project node, right-click the Test node, and choose New Test Case from the pop-up menu.
The New Test Case wizard opens.
- For Test Case Name, type successTest, and click Next.
- In the Select the WSDL Document page, expand the LoanRequestor - Process Files node, select LoanRequestor.wsdl, and click Next.
- In the Select the Operation to Test page, select the LoanRequestorOperation and click Finish.
In the Projects window, under Test, a new successTest node has been added.
This node contains two subnodes: Input and Output.
The Source Editor contains a tab for the Input file, Input.xml.
- If the Source Editor does not contain a tab for Input.xml, double-click the Input node in the Projects window to open the file.
- In the Source Editor tab for the Input.xml file, do the following:
- Locate the following line:
<loan:socialSecurityNumber>?string?</loan:socialSecurityNumber>.
- Replace ?string? with 123-45-6789.
The line should look like this:
<loan:socialSecurityNumber>123-45-6789</loan:socialSecurityNumber>.
- Repeat steps a and b to replace elements in the following lines:
Line Containing |
Replace |
With |
Resulting Line |
applicantName |
?string? |
Gopalan |
<loan:applicantName>Gopalan</loan:applicantName> |
applicantAddress |
?string? |
507 Alberta |
<loan:applicantAddress>507 Alberta</loan:applicantAddress> |
applicantEmailAddress |
?string? |
gopalan@sun.com |
<loan:applicantEmailAddress>gopalan@sun.com</loan:applicantEmailAddress> |
applicantAge |
?3? |
36 |
<loan:applicantAge>36</loan:applicantAge> |
applicantGender |
?string? |
male |
<loan:applicantGender>male</loan:applicantGender>. |
annualSalary |
?1.051732E7? |
100000 |
<loan:annualSalary>100000</loan:annualSalary> |
amountRequested |
?1.051732E7? |
1000000 |
<loan:amountRequested>1000000</loan:amountRequested>. |
|
- From the IDE's main menu, choose File > Save All.
- Double-click Output to examine its contents.
Initially, output.xml is empty. Therefore the first test run will populate output.xml with the real output. Subsequent test runs will compare the real output against the contents of output.xml.
- In the Projects window, right-click the successTest node and choose Run from the pop-up menu.
Note: The first run is a special case because Output.xml is empty and the output is written to Output.
Notice the failed message in the JUnit Test Results window.
The Overwrite Empty Output? dialog box opens.
- Click Yes.
- In the Projects window, right-click the successTest node and choose Run from the pop-up menu.
After the first run, Output is no longer empty. The file's contents are preserved and are not overwritten by the new result.

Click to enlarge
top
Creating BPEL Web Service Client
The customer submits the required information through a web service client.
To create the LoanApplicationWebclient web service client application:
- From the IDE's main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the Web node.
- In the Projects list, select the Web Application node.
- Click Next.
- In the Name and Location page, in the Project Name field, type LoanApplicationWebclient.
- Click Finish.
The Projects window now contains a project node for a web service client called LoanApplicationWebclient.
- In the Projects window, right-click the LoanApplicationWebclient project node and choose New >File/Folder.
The New File wizard opens.
- In the New File wizard, do the following:
- In the Choose File Type page, in the Categories list, select the Web Services node.
- In the File Types list, select the Web Service Client node.
- Click Next.
- In the WSDL and Client Location page, select the Local File option.
- Click the Browse button.
- In the Open dialog box, navigate to and select the LoanRequestor.wsdl file.
- Click Open.
- In the Package field, type loanprocesswsclient.
- Click Finish.
To create the loanclient.jsp page:
- In the Projects window, right-click the LoanApplicationWebclient project node and choose New > File/Folder.
- In the New File wizard, do the following:
- In the Choose File Type page, in the Categories list, select the Web node
- In the Choose File Type page, in the File Types list, select the JSP node
- Click Next.
- In the JSP File Name field, type loanclient and accept the defaults.
- Click Finish.
- In the Projects window, expand the LoanApplicationWebclient node and then expand the Web Pages node.
Notice that a loanclient.jsp node has been added and the loanclient.jsp file is opened in the Source Editor.
- In the Source Editor tab for the loanclient.jsp file, right-click to display the pop-up menu and select Web Service Client Resources > Call Web Service Operation.
- In the Select Option to Invoke dialog box, expand the LoanApplicationWebClient node and then expand the LoanRequestor node.
- Expand the LoanRequestorService node and then expand the LoanRequestorPort node.
- Select LoanRequestorOperation and click OK.

Click to enlarge
To modify the loanclient.jsp file:
- In the Source Editor tab for the loanclient.jsp file, add the following code lines under // TODO process result here:
requestLoanMessage.setSocialSecurityNumber(request.getParameter("ssn"));
requestLoanMessage.setApplicantName(request.getParameter("name"));
requestLoanMessage.setApplicantAddress(request.getParameter("address"));
requestLoanMessage.setApplicantEmailAddress(request.getParameter("email"));
requestLoanMessage.setApplicantAge(Integer.parseInt(request.getParameter("age")));
requestLoanMessage.setApplicantGender(request.getParameter("gender"));
requestLoanMessage.setAnnualSalary(Double.parseDouble(request.getParameter("salary")));
requestLoanMessage.setAmountRequested(Double.parseDouble(request.getParameter("loanamount")));
- In the Source Editor tab for the loanclient.jsp file, do the following:
- Locate the following line:
out.println("Result = "+result);
- Replace "+result with "+result.getReturn()
The line should look like this:
out.println("Result = "+result.getReturn());
- Add the code line below under // TODO handle custom exceptions here
out.println("===>>>Exception : " + ex.toString());
- Add the code line below under // <%-- end web service invocation --%><hr/>
<form action="index.jsp"> <input type="submit" value="Back To Loan Application"/> </form>
- To save your changes, in the Projects window, select the loanclient.jsp node, and from the IDE's main menu, choose File > Save.

Click to enlarge
To modify the index.jsp file:
- In the Projects window, expand the LoanApplicationWebclient project node, then expand the Web Pages node.
- Double-click the index.jsp node.
The index.jsp file opens in the Source Editor.
- Add the following code lines before </body>
<form action="loanclient.jsp">
<table>
<tr>
<td>SSN</td>
<td><input type="text" name="ssn" value="123456789"/></td>
<td></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" name="name" value="ORCHBank User"/></td>
<td></td>
</tr>
<tr>
<td>Address</td>
<td><input type="text" name="address" value="16 Network Circle, Menlo Park,CA" /></td>
<td></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" value="orchbankuser@bankmail.com" /></td>
<td></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="age" value="27" /></td>
<td>Age Limit : Min = 18, Max = 65, (If age exceeds 60 BPEL engine's rule rejects the application)</td>
</tr>
<tr>
<td>Gender</td>
<td><input type="text" name="gender" value="male" /></td>
<td></td>
</tr>
<tr>
<td>Salary</td>
<td><input type="text" name="salary" value="56789.10" /></td>
<td>Minimum Salary = 20000.00</td>
</tr>
<tr>
<td>Loan Amount</td>
<td><input type="text" name="loanamount" value="19500.00" /></td>
<td></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="submit" name="Submit Application" /></td>
</tr>
<td></td>
</table>
</form>
- To save your changes, in the Projects window, select the index.jsp node, and from the IDE's main menu, choose File > Save.
To run the index.jsp file:
- In the Projects window, expand the LoanApplicationWebclient node, then expand the Web Pages node.
- Expand the WEB-INF node and select index.jsp
- Right-click the index.jsp file, and choose Run File from the pop-up menu.
- In the Output window, the URL that the index.jsp is browsing and BUILD SUCCESSFUL message appear if the build has succeeded.
- A browser appears. If not, launch a browser and type in the URL
that is listed in the LoanApplicationWebclient (run) tab of the Output
window.
The JSP Page displays.

Click to enlarge
- In your browser, in the JSP Page, click the submit button.
Loan Application Status is displayed.
top
----------------------------------------
Appendix
To create EJB project
To create EJB Module:
- From the IDE's main menu, choose File >New Project.
- Under Categories select the Enterprise node.
- Under Projects, select the EJB Module node.
- Click Next.
- In the Project Name field, type LoanProcessor.
- (Optional) In the Project Location field, use the Browse button to
navigate to and select a different folder where the IDE will store the
EJB project files.
- Click Finish.
The Projects window now contains a project node for an EJB Module project called LoanProcessor.
To create new web services:
- In the Projects window, right-click the LoanProcessor node, choose New > Web Service from the context menu.
The New Web Service wizard opens.
- In the New Web Service wizard, do the following:
- In the Name and Location page, in the Web Service Name field, type LoanProcessor.
- In the Package field, type com.sun.loanprocessor.
- Click Finish
- In the Projects window, expand the LoanProcessor project node, then expand the Web Services node.
- Right-click the LoanProcessor node and choose Add Operation.
The Add Operation dialog box opens.
- In the Name field, type processApplication.
- Click the Add button.
The Enter Method Parameter dialog box opens.
- In the Type drop-down list, select String.
- In the Name, type socialSecurityNumber.
- Click OK.
- Repeat steps 6 to 8 to create six other parameters with the following description:
Type
|
Name
|
String |
applicantName |
String |
applicantAddress |
String |
applicantEmailAddress |
int |
applicantAge |
String |
applicantGender |
double |
annualSalary |
double |
amountRequested |
- Click OK.
- In the Projects window, expand the LoanProcessor project node, then expand the Web Services node.
- Expand the LoanProcessor web service and double-click the processApplication node.
Notice that the Source Editor contains a tab with a skeleton for the processApplication method, LoanProcessor.java.
- Copy the body of the method below and paste it in the Source Editor tab for the LoanProcessor.java
file, immediately under the signature of your automatically generated
method, to change the processApplication operation to the following:
public String processApplication(@WebParam(name = "socialSecurityNumber") String socialSecurity,
@WebParam(name = "applicantName")String applicantName, @WebParam(name = "applicantAddress") String applicantAddress,
@WebParam(name = "applicantEmailAddress")String applicantEmailAddress,
@WebParam(name = "applicantAge") int applicantAge, @WebParam(name = "applicantGender")String applicantGender,
@WebParam(name = "annualSalary") double annualSalary, @WebParam(name = "amountRequested")double amountRequested) {
int MINIMUM_AGE_LIMIT = 18;
int MAXIMUM_AGE_LIMIT = 65;
double MINIMUM_SALARY = 20000;
int AVERAGE_LIFE_EXPECTANCY = 70;
String result = "Loan Application APPROVED.";
if(applicantAge < MINIMUM_AGE_LIMIT) {
result = "Loan Application REJECTED - Reason: Under-aged "+applicantAge+". Age needs to be over "+MINIMUM_AGE_LIMIT+"
years to qualify.";
System.out.println(result);
return result;
}
if(applicantAge > MAXIMUM_AGE_LIMIT) {
result = "Loan Application REJECTED - Reason: Over-aged "+applicantAge+". Age needs to be under "+MAXIMUM_AGE_LIMIT+"
years to qualify.";
System.out.println(result);
return result;
}
if(annualSalary < MINIMUM_SALARY) {
result = "Loan Application REJECTED - Reason: Annual Salary $"+annualSalary+" too low. Annual Salary needs to be
over $"+MINIMUM_SALARY+" to qualify.";
System.out.println(result);
return result;
}
int yearsToRepay = AVERAGE_LIFE_EXPECTANCY-applicantAge;
double limit = annualSalary*yearsToRepay*0.5;
if(amountRequested > limit) {
result = "Loan Application REJECTED - Reason: You are asking for too much $"+amountRequested+".
Annual Salary $"+annualSalary+", Age "+applicantAge+" years.
Your limit is $"+limit;
System.out.println(result);
return result;
}
System.out.println(result);
return result;
}
- To save your changes choose File > Save from the IDE's main menu.
top
Copyright and Trademark Notice