sql.DataSource ds =
(javax.sql.DataSource)initialContext.lookup(???java:com
p/env/jdbc/AjaxTagsConnectionDS???);
java.sql.Connection conn = ds.getConnection();
String catalogId = request.getParameter(???catalogId???);
String journal = request.getParameter(???journal???);
String publisher = request.getParameter(???publisher???);
String edition = request.getParameter(???edition???);
String title = request.getParameter(???title???);
118 6 Ajax without JavaScript ??“ AjaxTags
String author = request.getParameter(???author???);
Statement stmt = conn.createStatement();
String sql = ???INSERT INTO Catalog VALUES(??? + ???\??™??? +
catalogId + ???\??™??? + ???,??? +
???\??™??? + journal + ???\??™??? + ???,??? + ???\??™??? +
publisher + ???\??™??? + ???,??? +
???\??™??? + edition + ???\??™??? + ???,??? + ???\??™??? +
title + ???\??™??? + ???,??? +
???\??™??? + author + ???\??™??? + ???)???;
stmt.execute(sql);
response.sendRedirect(???catalog.jsp???);
stmt.close();
conn.close();
} catch (javax.naming.NamingException e) {
response.sendRedirect(???error.jsp???);
} catch (SQLException e) {
response.sendRedirect(???error.jsp???);
}
}
}
Copy FormServlet class to the FormServlets.java class in
AjaxTags project in JDeveloper. Next, update the input form fields with
catalog entry values for a Catalog Id for which a catalog entry is already
defined in the database table. Add an ajax:updateField tag to
update form fields.
Pages:
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118