In this section, you will create the edit.jsp
file that enables users to update an employee record.
edit.jsp
. Accept all other defaults.jsp:usebean
tag. Enter empsbean
as the ID, and hr.DataHandler
as the Class. Set the Scope to session
, and click OK.jsp:usebean
tag. This time enter employee
as the ID, browse to select hr.Employee as the class, and leave the Scope as page. Click OK.findEmployeeById
method and retrieves the data inside the Employee
bean. Enter the following code in the Insert Scriptlet dialog box:
Integer employee_id = new Integer(request.getParameter("empid")); employee = empsbean.findEmployeeById(employee_id.intValue());
update_action.jsp
for the Action field. You cannot select this page from the list as you have not yet created it.First Name
, Last Name
, Email
, Phone
, Job
, Monthly Salary
.employee_id
as the Name property and enter <%= employee.getEmployeeId()%>
as the Value property.first_name
in the Name field, and <%= employee.getFirstName()%>
in the Value field. Click OK.last_name
in the Name field, and <%= employee.getLastName() %>
in the Value
field. Click OK.email
, phone_number
, job_id
, and salary
as the field names and the corresponding getter method for each field. These are specified in the following table.
Name Field | Value Field |
---|---|
|
|
|
|
|
|
|
|
Update
as its Value.The resultant edit.jsp
page should look similar to the page shown in Figure 5-4.
Figure 5-4 Creating a JSP Page to Edit Employee Details