Java Reference
In-Depth Information
}
}
}
catch(ClassNotFoundException e){
e.printStackTrace();
}
catch(SQLException e){
e.printStackTrace();
}
}
}
Note that the sequence of events is the same as in the previous example:
1. The CallableStatement is created using prepareCall() .
2. The CallableStatement 's parameters are set.
3. The CallableStatement is executed, in this instance returning a ResultSet .
In this example, a simple type check is performed on the returned values to ensure that the right getter
method is used to retrieve the data.
Using a StoredProcedure from a JSP Bean
Now that the stored procedure has been created, it is called from a JavaBean instantiated from a JSP
page. The JSP page itself is called from the action method of the HTML form displayed as part of the
member-registration process. The form itself is shown in Figure 13-1 .
Figure 13-1: A basic name and address form used to provide data for the Contact_info Table
The HTML to create this form is shown in Listing 13-5 . Note that a simple validation script has been
included to ensure that at least some data is entered for each of the important fields. This form is saved
as NewMemberForm.jsp and is called from theProcessLogin.jsp form handler shown in Listing
12-8 .
Listing 13-5: Registration form NewMemberForm.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
Search WWH ::




Custom Search