out.println(builder.toString());
The FormUpdateServlet class is listed below.
package ajaxtags;
import java.io.*;
import java.sql.*;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.*;
import org.ajaxtags.helpers.AjaxXmlBuilder;
public class FormUpdateServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
try {
// Obtain value of Catalog Id field to ve validated.
String catalogId = request.getParameter(???catalogId???);
if (catalogId.equals(???Select Catalog Id???)) {
AjaxXmlBuilder builder = new AjaxXmlBuilder();
response.setContentType(???text/xml???);
response.setHeader(???Cache-Control???, ???no-cache???);
PrintWriter out = response.getWriter();
builder.addItem(???journal???, null);
builder.addItem(???publisher???, null);
builder.addItem(???edition???, null);
builder.addItem(???title???, null);
builder.addItem(???author???, null);
out.println(builder.toString());
}
if (!(catalogId.equals(???Select Catalog Id???))) {
// Obtain Connection
InitialContext initialContext = new InitialContext();
javax.sql.DataSource ds =
6.5 Validating a Form with AjaxTags 121
(javax.sql.DataSource)initialContext.lookup(???java:com
p/env/jdbc/AjaxTagsConnectionDS???);
java.sql.Connection conn = ds.getConnection();
// Obtain result set
Statement stmt = conn.
Pages:
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121