Let’s have a closer look at this piece of code to see how it works.
A. Two JSP directives are declared first, and they are used to set up the Java bean, session, class and property used on this JSP page. The Update _ Course() method is to be built in our Java bean class later, and the underscore between the Update and the Course is to distinguish this method from a similar operation, UpdateCourse(), in our Web Service. These two directives must not be enclosed by a pair of <% . . . %> symbols.
B. Starting from step B, the following code will be Java code to be embedded into this page, so an opening symbol, <%, is used to start this part. Since the Web operation UpdateCourse() in our Web Service returns a boolean result, to hold it, a local boolean variable, res, is created and initialized first.
C. To set up an updated course record that contains six pieces of updated course information, seven system methods, getParameter(), are used to pick up each piece of updated course information (including course _ id, but it will not be updated) from the related TextField in our client page, Course.jsp, and assign each of them to a local String variable.
D. Then a String[] array is created and initialized with those seven local variables (keep course _ id with no change) to make an updated course record ready to be sent to the Java bean class in the next step.
E. The Update _ Course() method that will be defined in our Java bean class is executed with the initialized String[] as the argument. The run result of this method is returned and assigned to our local boolean variable res.
F. If a false is returned, which means that the execution of this method fails, then the client page, Course.jsp, is refreshed to make it ready for the next operation.
G. Otherwise, the running of the method is successful, and the selected course record is updated in the Course Table in our sample database, so all TextFields in the client page will be reset to null to allow users to check the updateresult.

FIGURE 9.110 The code for the Update_Course() method in the Java bean.
Next let’s handle the coding process in our Java bean class file, CourseQuery.java. Double-click on this file in the Projects window in the folder, Source Packages\JavaWeb OracleSelectPackage, to open it, and enter the code shown in Figure 9.110 into the bottom of this file. Let’s have a closer look at this piece of code to see how it works.
A. Two local variables, update and al, are generated first. The former is a Boolean variable used to hold the run result of execution of our Web Service operation, UpdateCourse(), and the latter is an instance of the ArrayList class, which is used to store seven pieces of information for an updated course record.
B. The ArrayList instance al is cleaned up by using the clear() method to make sure that al is empty before it can be used to store any data.
C. A sequence of add() methods is used to add all six pieces of updated course information (including course _ id) into the ArrayList instance al, which will be passed as an argument to our Web Service operation UpdateCourse() later.
D. A try-catch block is used to call our Web operation, UpdateCourse(), to update a selected course record in our sample database via our Web service. First a new Web service instance, service, is created based on our Web service class WebServiceCourse _ Service. Then the getWebServiceCoursePort() method is executed to get the current port used by our Web service. This port is returned and assigned to a new port instance, port.
E. The Web Service operation UpdateCourse() is executed with an argument, al, that contains all pieces of updated course information, and the run result is returned and assigned to the local Boolean variable update.
F. If the returned Boolean value is false, which means that this data update action fails, a system method, println(), is used to indicate this situation. Otherwise, the data update is successful.
G. The catch block is used to monitor and check any possible exception during the data update process. A false is returned to the calling program if any error occurs.
H. Otherwise, a true is returned to indicate the success of this data update action.