String catalogId = request.getParameter(???catalogId???);
if (catalogId.equals(???Select Catalog Id???)) {
response.setContentType(???text/html???);
response.setHeader(???Cache-Control???, ???no-cache???);
PrintWriter out = response.getWriter();
out.println(???
???);
6.5 Validating a Form with AjaxTags 117
}
if (!(catalogId.equals(???Select Catalog Id???))) {
// Obtain Connection
InitialContext initialContext = new InitialContext();
javax.sql.DataSource ds =
(javax.sql.DataSource)initialContext.lookup(???java:com
p/env/jdbc/AjaxTagsConnectionDS???);
java.sql.Connection conn = ds.getConnection();
// Obtain result set
Statement stmt = conn.createStatement();
String query = ???SELECT * from OE.Catalog WHERE
CatalogId=??? + ?????™??? + catalogId + ?????™???;
ResultSet rs = stmt.executeQuery(query);
// set headers before accessing the Writer
response.setContentType(???text/html???);
response.setHeader(???Cache-Control???, ???no-cache???);
PrintWriter out = response.getWriter();
// then write the response
// If result set is empty set valid element to true
if (rs.next()) {
out.println(???
Catalog Id is not Valid
???);
} else {
out.println(???
Catalog Id is Valid
???);
}
rs.close();
stmt.close();
conn.close();
}
} catch (javax.naming.NamingException e) {
} catch (SQLException e) {
}
}
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
try {
// Obtain Connection
InitialContext initialContext = new InitialContext();
javax.
Pages:
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117