9.16.6 Build Our Client Project to Update Course Records via Our Web Service
Generally there is no need to update a course _ id when updating a course record, since a better way to do that is to insert a new course record and delete the old one. The main reason for this is that a very complicated cascaded update process would be performed if a course _ id were updated, since it is a primary key in the Course Table but a foreign key in the StudentCourse Table. To update a primary key, one needs to update foreign keys first in the child Tables and then update the primary key in the parent Table. This will make our updateprocess very complicated. In order to avoid this confu-sion, in this section, we will update a course record by changing any column except the course _ id, and this is a popular way to update a Table and widely implemented in most database applications.

FIGURE 9.108 The opened Course Table in our sample database.
To save time and space, we can modify one of our projects, WebClientCourse _ Insert, we built in the last section and make it our new project. Perform the following operations to make our new project, WebClientCourse _ Update:
1) Open NetBeans IDE 12.0 in Administrator mode and right-click on the project
WebClientCourse _ Insert in the Projects window. Then select the Copy item from the popup menu to open the Copy Project wizard.
2) Enter our new project name, WebClientCourse _ Update, into the Project Name box, and browse to your local project folder as the Project Location, and click on the Copy button. A new project, WebClientCourse _ Update, is generated and added into our Projects window.
After this new project is generated, a few errors may occur in our Java Bean class file CourseQuery.java. To fix those errors, just build our new project by clicking on the Clean and Build Project button on the top to update the Web Service reference.
Now let’s develop the code for the Update button in our client project, that is, in the client page Course.jsp, to update a course record via our Web Service. The main code concentrates on two files, the transaction page, CourseProcess.jsp, and our Java bean class file, CourseQuery. java. Let’s first take care of the code development for the transaction page, CourseProcess.jsp.
The main function of this piece of code is to coordinate the update query and provide a valid interface between the client page and the Java bean to make that query smoother.
Double-click on this page in the Projects window to open it and enter the code shown in Figure 9.109 into this page, that is, into the else if (request.getParameter(“Update”)!= null) block.

FIGURE 9.109 The code for the Update Course block in the CourseProcess.jsp page.