SQL

 

 

Properties

 

 

-JdbcDriver

 

 

-LoginID

 

 

-Password

 

 

-JdbcServer

 

 

-Schema

 

 

-Action

 

 

Recurse

Servlet

instantiate

XMLToSQL

 

 

 

 

execute

 

 

XML Document

Figure 11-5

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 11-1);

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

Page 280
Image 280
IBM Version 5 manual Modifying CustomerXSLServlet, Initializing the XMLToSQL class