December 2000
Intermediate to advanced
574 pages
17h 3m
English
The
classes described in this chapter can
also be used for application-specific components that access a
database. Chapter 15 includes one example of an
application-specific bean, the
EmployeeRegisterBean, that uses the
SQLCommandBean to execute its SQL statements.
You can also use these classes in your application-specific custom actions. One example is the custom action that’s mentioned in Chapter 9 as an alternative to the generic database actions for inserting or updating employee information:
<%@ page language="java" contentType="text/html" %> <%@ taglib uri="/orataglib" prefix="ora" %><%@ taglib uri="/mytaglib" prefix="myLib" %><myLib:saveEmployeeInfo dataSource="example" /><%-- Get the new or updated data from the database --%> <ora:sqlQuery id="newEmpDbInfo" dataSource="example" scope="session"> SELECT * FROM Employee WHERE UserName = ? <ora:sqlStringValue param="userName" /> </ora:sqlQuery> <%-- Redirect to the confirmation page --%> <ora:redirect page="confirmation.jsp" />
Example 17.27 shows one way to implement this custom action.
Example 17-27. SaveEmployeeInfoTag Class
package com.mycompany.tags; import java.sql.*; import java.text.*; import java.util.Vector; import javax.sql.*; import javax.servlet.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import com.ora.jsp.sql.*; import com.ora.jsp.sql.value.*; import com.ora.jsp.util.*; public class SaveEmployeeInfoTag extends TagSupport { private String ...Read now
Unlock full access