9.7.3 Modify Three Files to Make Them Work for Our Web Client Project
We need to modify the following three class files to make them work for our client project:
1) Modify our view class, Faculty.jsp, to display the selected faculty image and to termi-nate our Web client project when the Back button is clicked by the user.
2) Modify our control class, FacultyProcess.jsp, to make decisions to perform appro-priate operations by calling related methods in our Java Bean class or our model class, and setup the correct mapping between our view and model classes.
3) Modify our Java Bean or model class, FacultyMBean.java, to handle all operations required by our control class by calling related Web service operations.
First let’s modify our view class Faculty.jsp file. Open this file and go to codeline 127, where the image source tag is assigned by the selected faculty image. Change that line from
src=“data:image/jpg;base64,${FacultyQuery.base64Image}” to src=“data:image/jpg;base64,${FacultyMBean.base64Image}”
since our new created Java Bean class is named FacultyMBean, not FacultyQuery, which was used by the previous project, JavaWebOracleSelect, we built in Chapter 8.
The next modification is to change one code line in the bottom of the JSP file, Faculty.jsp, to safely terminate our Web consume client project. Open this JSP file Faculty.jsp and browse to the bottom of that file, around line 520. Replace the original line:
with the following line:
The reason for this change is because the Faculty.jsp page in our previous projects will be returned to the Selection.jsp page if this Back button is clicked by the user, but in this Web Client project, WebClientFaculty _ Select, we only rebuild the Faculty.jsp page without using any other pages; thus, we need to modify the code in the Back button event handler to terminate this project.
Now let’s modify the FacultyProcess.jsp file to make it our new control class:
1) Replace the import package name <%@ page import=“JavaWebDBJSPSQLPackage
.” %> with our new package <%@ page import=“webclient.” %> in codeline 10.
2) Replace the original constructor line (line 20), FacultyQuery fQuery = new FacultyQuery(); with our new Java Bean class FacultyMBean fQuery = new FacultyMBean();.
3) Go to code line 40 and change the FacultyQuery to FacultyMBean, and the result of that code line should be:
request.setAttribute(“FacultyMBean”, fQuery);
4) Remove the entire block else if (request.getParameter(“Back”)!= null) {} located at the bottom, at lines 122–125, since we do not want to use the Back button to return to any other page.