Java Reference
In-Depth Information
The most noticeable error is that the value null is displayed where employee number is supposed to appear.
A look at the JSP code shows that there is an expression to retrieve the employee number, however, a look into at the
EmpExtractor source code shows that empNum property is never set. Obviously, this needs to be fixed.
Although not errors, we should make some formatting improvements. For instance, the data values should be left
justified so they are nearer the labels (yours may already be left justified) and made bold to differentiate them from the
labels and emphasize them as results.
15.
In the Design view, modify the JSP so that the data is formatted as in Figure 9-11 .
Figure 9-11.
16.
Add the following statement to getEmployeeInstance in EmpExtractor and save the
source code:
emp.setEmpNum(request.getParameter("empNumTF"));
This statement retrieves the employee number from the request object and sets the Employee object's employee
number property.
Steps 15 and 16 should result in the page displaying the employee number instead of null as in Figure 9-11 .
The source code for DispEmpInfoJSP should be as follows:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"
import="c9java.*"%>
<jsp:scriptlet> Employee emp;
EmpExtractor ee = new EmpExtractor();
emp = ee.getEmployeeInstance(request);
</jsp:scriptlet>
<html>
<head>
<title>DispEmpInfoJSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR"
content="Rational® Application Developer for WebSphere® Software">
</head>
 
Search WWH ::




Custom Search