Java Reference
In-Depth Information
9.
Click the Confirm button.
The EmpDel JSP should be run, resulting in the employee record for Tracy Tester being deleted from the
database. The browser will display the text that confirms that the record was deleted (see Figure 11-19 ).
Figure 11-19.
10.
To verify that the record was deleted, use the browser's back button to redisplay the Enter-
EmpInfoJSP with the employee number 444 specified.
11. Specify Joe as the employee name, FL as the State, 15 for the pay rate, Display as the
function and click the Submit button.
The browser will display the information entered above. This means that there was no information for employee
444 in the database to override the information entered in step 11, which confirms that the Tracy Tester information
was deleted from the database.
Checking the Console view will also show a message saying there was a problem getting information from the
result set (in the Employee class). Which makes sense because there was nothing returned in the result set when the
select statement for employee number 444 was executed.
The server-based application has been upgraded, but to make the coding easier we have violated some standards
and introduced inefficiencies. One violation that we have not pointed out is that the application does not separate
the view and controller functions. The JSP pages contain forward tags. Really, a servlet should be performing this
controller function. The advantage to using a servlet is that if a new page were added or deleted, no other pages would
be modified. The MVC architecture would ensure that any navigation changes would be made in one place, the
servlet, and not affect the JSPs that comprise the view.
In addition, the application has not been very careful about creating and closing multiple connections. For
instance, instead of creating a connection each time an Employee object is created, it would have been more efficient
to create a connection when the application is started and then have all the employee objects use that connection.
Fortunately, the next chapter covers Java Server Faces, which provides easy tools to make these improvements.
Search WWH ::




Custom Search