Hi, i have tried to get the sample code in the taglib help page to work with no success. Can anyone point me in the right direction ?
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body>
hello <db:getConnection id="myConnection" >
<sql:statement id="stmt" conn="myConnection"> <sql:query>Select * from users</sql:query> <sql:resultSet id="rs"> <sql:getColumn position="1"/> <sql:getColumn position="2"/> <sql:getColumn position="3"/> <sql:getColumn position="4"/> <sql:getColumn position="5"/> </sql:resultSet> </sql:statement> </db:getConnection>
</body> </html>
my HTML produced from above is
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body>
hello
<sql:statement id="stmt" conn="myConnection"> <sql:query>Select * from users</sql:query> <sql:resultSet id="rs"> <sql:getColumn position="1"/> <sql:getColumn position="2"/> <sql:getColumn position="3"/> <sql:getColumn position="4"/> <sql:getColumn position="5"/> </sql:resultSet> </sql:statement>
Try to add the taglib definition of the jstl!
Henner
Ok tried that with the following
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %> <%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body>
hello <db:getConnection id="myConnection" > <sql:statement id="stmt" conn="myConnection"> <sql:query>Select * from users</sql:query> <sql:resultSet id="rs"> <sql:getColumn position="1"/> <sql:getColumn position="2"/> <sql:getColumn position="3"/> <sql:getColumn position="4"/> <sql:getColumn position="5"/> </sql:resultSet> </sql:statement> </db:getConnection>
then I get the following exception
exception
org.apache.jasper.JasperException: /userupdate.jsp(12,0) No tag "statement" defined in tag library imported with prefix "sql"
From the bookstore example:
<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"--> <%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %> <%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %> <%@ taglib uri="/WEB-INF/c-el.tld" prefix="c" %> <head> <dbE:base/> </head> <html> <body> <db:setDataSource dataSource="con" /> <sql:query dataSource="${con}" var="qry"> select * from BOOK </sql:query> <table border="1"> <c:forEach var="row" items="${qry.rows}"> <tr> <td> <c:out value="${row.isbn}"/> </td> <td> <c:out value="${row.title}"/> </td> </tr> </c:forEach> </table> </body> </html>
Hi Henner, thanks for the pointers. The following is what I finally got to work Many thanks
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %> <%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %> <%@ page import="java.util.*,java.net.*,java.io.*,java.sql.*,javax.naming.*,javax.sql.*" %>
<db:setDataSource dataSource="con" /> <sql:update dataSource="${con}" > UPDATE userstest SET expire = 'xxx' WHERE user_name = 'xxx' </sql:update>
Log in to post a comment.
Hi,
i have tried to get the sample code in the taglib help page to work with no success. Can anyone point me in the right direction ?
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
hello
<db:getConnection id="myConnection" >
<sql:statement id="stmt" conn="myConnection">
<sql:query>Select * from users</sql:query>
<sql:resultSet id="rs">
<sql:getColumn position="1"/>
<sql:getColumn position="2"/>
<sql:getColumn position="3"/>
<sql:getColumn position="4"/>
<sql:getColumn position="5"/>
</sql:resultSet>
</sql:statement>
</db:getConnection>
</body>
</html>
my HTML produced from above is
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
hello
<sql:statement id="stmt" conn="myConnection">
<sql:query>Select * from users</sql:query>
<sql:resultSet id="rs">
<sql:getColumn position="1"/>
<sql:getColumn position="2"/>
<sql:getColumn position="3"/>
<sql:getColumn position="4"/>
<sql:getColumn position="5"/>
</sql:resultSet>
</sql:statement>
</body>
</html>
Try to add the taglib definition of the jstl!
Henner
Ok tried that with the following
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>
<%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
hello
<db:getConnection id="myConnection" >
<sql:statement id="stmt" conn="myConnection">
<sql:query>Select * from users</sql:query>
<sql:resultSet id="rs">
<sql:getColumn position="1"/>
<sql:getColumn position="2"/>
<sql:getColumn position="3"/>
<sql:getColumn position="4"/>
<sql:getColumn position="5"/>
</sql:resultSet>
</sql:statement>
</db:getConnection>
</body>
</html>
then I get the following exception
exception
org.apache.jasper.JasperException: /userupdate.jsp(12,0) No tag "statement" defined in tag library imported with prefix "sql"
From the bookstore example:
<!--DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>
<%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %>
<%@ taglib uri="/WEB-INF/c-el.tld" prefix="c" %>
<head>
<dbE:base/>
</head>
<html>
<body>
<db:setDataSource dataSource="con" />
<sql:query dataSource="${con}" var="qry">
select * from BOOK
</sql:query>
<table border="1">
<c:forEach var="row" items="${qry.rows}">
<tr>
<td>
<c:out value="${row.isbn}"/>
</td>
<td>
<c:out value="${row.title}"/>
</td>
</tr>
</c:forEach>
</table>
</body>
</html>
Henner
Hi Henner,
thanks for the pointers. The following is what I finally got to work
Many thanks
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>
<%@ taglib uri="/WEB-INF/sql.tld" prefix="sql" %>
<%@ page import="java.util.*,java.net.*,java.io.*,java.sql.*,javax.naming.*,javax.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<db:setDataSource dataSource="con" />
<sql:update dataSource="${con}" > UPDATE userstest SET expire = 'xxx' WHERE user_name = 'xxx' </sql:update>
</body>
</html>