
|
| SQL | |
|
| Properties | |
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| ||
|
| Recurse | |
Servlet | instantiate | ||
XMLToSQL | |||
|
| ||
|
| execute | |
|
| XML Document | |
Figure | XMLToSQL |
| |
11.3.4 Modifying CustomerXSLServlet
The change to the CustomerXSLServlet is the doPost method of the servlet, which enables storing new customer records in the database. Since doGet returns the blank input form, we left as is. To achieve our target, we need to perform the following to the CustomerXSLServlet:
Initialize XMLToSQL to work with the database.
Modify the doPost method to execute the insert.
Initializing the XMLToSQL class
We created separate initSQLProperties method to setup the property. Since we use same property during this application running, we initialize this property in the init method.
Add SqlProperties as a global variable: private SQLProperties sqlProperties;
Add XMLToSQL as a global variable: private XMLToSQL xml2sql;
Add initSQLProperties method (Example
We recommend that you create a .properties file to keep the information to set the SQLProperties.
In the init method, add a statement to invoke the initSQLProperties method:
264 The XML Files: Development of XML/XSL Applications Using WebSphere Studio