Main Topics
Browse All TopicsHi,
Please kindly assist what changes needs to be on the code below to incorporate the new tablib
I'm not sure how to join the new tag lib code
http://displaytag.sourcefo
--------------------------
<%
Connection con = ...; // just open a connection
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from table");
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
stmt.close();
con.close();
request.setAttribute("resu
%>
--------------------------
<code>
<%@ page import="java.sql.*, com.my.beans.*" %>
<jsp:useBean id="beanconnection" class="com.my.beans.Connec
<html>
<body>
<%
String sql = "Select ID,Name from employees" ;
ResultSet rs = beanconnection.executeQuer
%>
<%
while ( rs.next() ){
%>
A line of db stuff <%= rs.getString("Name") %>
<%
}
%>
</body>
</html>
</code>
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
download
http://apache.sunsite.ualb
that code will automatically display the table
so
<code>
<%@ page import="java.sql.*, com.my.beans.*" %>
<jsp:useBean id="beanconnection" class="com.my.beans.Connec
<html>
<body>
<%
String sql = "Select ID,Name from employees" ;
ResultSet rs = beanconnection.executeQuer
%>
<%
while ( rs.next() ){
%>
A line of db stuff <%= rs.getString("Name") %>
<%
}
%>
</body>
</html>
</code>
becomes
<code>
<%@ page import="java.sql.*, com.my.beans.*" %>
<jsp:useBean id="beanconnection" class="com.my.beans.Connec
<html>
<body>
<%
Connection con = ...; // just open a connection
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from table");
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
stmt.close();
con.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
</code>
i got the code to work.
you need to download the following libraries:
http://prdownloads.sourcef
http://apache.mirror.cygna
and the one i mentioned earlier.
you need the following at the top of your page:
<%@ taglib uri="http://displaytag.sf.
and you need to follow these install instructions
http://displaytag.sourcefo
kawas,
I'm using Tomcat 5.5 and mysql 4.1 as server
on my desktop, nitrox is displaying couple of errors..
<code>
<%@ page import="java.sql.*, com.my.beans.*" %>
<%@ taglib uri="http://displaytag.sf.
<jsp:useBean id="beanconnection" class="com.my.beans.Connec
<html>
<body>
<%
Connection con= null;
Class.forName("com.mysql.j
con = DriverManager.getConnectio
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from table");
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false); <--red underline error (cannot be resolve to a type)
stmt.close();
con.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
</code>
have you installed all of the libraries?
in the WEB_INF/lib directory, i added the following libs:
commons-beanutils.jar
commons-beanutils-bean-col
commons-beanutils-core.jar
commons-lang-2.1.jar
displaytag-1.0.jar
in the WEB-INF/ directory I added (came from display tag):
displaytag-11.tld
displaytag-12.tld
displaytag-el-12.tld
added the following import
<%@ taglib uri="http://displaytag.sf.
restart your server
and try again. My editor didnt like that statement either.
Make sure that you start up mysql and that you also have the sql connector in you WEB-INF/lib directory
why would there be a java file? it should be .jsp
<html>
<head><title>Query Results</title></head>
<body>
<!-- import needed for the SQL-database access things -->
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons
<%@ taglib uri="http://displaytag.sf.
<%
Connectionconnection = DriverManager.getConnectio
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * from object");
RowSetDynaClass resultSe2 = new RowSetDynaClass(rs, false);
stmt.close();
connection.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
<html>
<head><title>Query Results</title></head>
<body>
<!-- import needed for the SQL-database access things -->
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons
<%@ taglib uri="http://displaytag.sf.
<%
Connection connection = null;
Class.forName("com.mysql.j
connection = DriverManager.getConnectio
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * from object");
RowSetDynaClass resultSe2 = new RowSetDynaClass(rs, false);
stmt.close();
connection.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
i really am mucking it up. sorry, i was trying to remove other code from the file and kept pasting code from the wrong section
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons
<%@ taglib uri="http://displaytag.sf.
<html>
<head><title>Query Results</title></head>
<body>
<%
Connection connection = null;
Class.forName("com.mysql.j
connection = DriverManager.getConnectio
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * from object");
RowSetDynaClass resultSe2 = new RowSetDynaClass(rs, false);
stmt.close();
connection.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
oh boy, one last time
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons
<%@ taglib uri="http://displaytag.sf.
<html>
<head><title>Query Results</title></head>
<body>
<%
Connection connection = null;
Class.forName("com.mysql.j
connection = DriverManager.getConnectio
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * from object");
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
stmt.close();
connection.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
kawas,
yup, I followed your advice,
Error message:The import org.apache.commons cannot be resolved
still persist <%@ page import="org.apache.commons
Thanks.
in the WEB_INF/lib directory,
commons-beanutils.jar
commons-beanutils-bean-col
commons-beanutils-core.jar
commons-lang-2.1.jar <-------------------------
displaytag-1.0.jar
in the WEB-INF/ directory
displaytag-11.tld
displaytag-12.tld
displaytag-el-12.tld
in the WEB-INF/lib
mysql connector 3.1.11-bin.jar
kawas,
when I run the project, error message:
exception
javax.servlet.ServletExcep
org.apache.jasper.runtime.
org.apache.jasper.runtime.
org.apache.jsp.index_jsp._
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NoClassDefFoundE
org.displaytag.tags.TableT
org.displaytag.tags.TableT
org.apache.jsp.index_jsp._
org.apache.jsp.index_jsp._
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
http://apache.mirror.cygna
apparently you may need the commons-collections as well
http://apache.mirror.rafal
other than that, it looks good. if the error persists, look into the /tomcat/logs/localhost***.
kawas,
sad to say still same error as posted above.
please kindly see link for files in lib http://geocities.com/eefor
maybe you have added something in web.xml ?
web server is on tomcat 5.5 and mysql 4.1
Thanks.
kawas,
Please kindly see below for the last 100 line in catalino.out file
http://pastebin.com/393740
<%@ page import="java.sql.*" %>
<%@ page import="org.apache.commons
<%@ taglib uri="http://displaytag.sf.
<html>
<head><title>Query Results</title></head>
<body>
<%
Connection connection = null;
Class.forName("org.gjt.mm.
connection = DriverManager.getConnectio
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * from employees");
RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
stmt.close();
connection.close();
request.setAttribute("resu
%>
<display:table name="requestScope.results
</body>
</html>
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com
xmlns:xsi="http://www.w3.o
xsi:schemaLocation="http:/
version="2.4">
<display-name>Web Application</display-name>
<context-param>
<param-name>javax.servlet.
<param-value>resources.app
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</w
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>http://java.su
<taglib-location>/WEB-INF/
</taglib>
<taglib>
<taglib-uri>http://java.su
<taglib-location>/WEB-INF/
</taglib>
<taglib>
<taglib-uri>http://java.su
<taglib-location>/WEB-INF/
</taglib>
<taglib>
<taglib-uri>http://java.su
<taglib-location>/WEB-INF/
</taglib>
<taglib>
<taglib-uri>http://java.su
<taglib-location>/WEB-INF/
</taglib>
</jsp-config>
</web-app>
kawas,
I can feel were getting closer, That means, i'm missing some files ?
here are the problems listed in Nitrox: (paste then in notepad)
Severity Description Resource In Folder Location Creation Time Id
2 RowSetDynaClass cannot be resolved to a type index.jsp datagrid/web October 14, 2005 3:40:07 PM 74
2 The import org.apache.commons cannot be resolved index.jsp datagrid/web October 14, 2005 2:33:50 PM 61
1 The tei class org.displaytag.tags.TableT
Thanks.
add
<taglib>
<taglib-uri>http://display
<taglib-location>/WEB-INF/
</taglib>
to your jsp-config section of the web.xml
i think that you will need to associate a css style sheet with the table.
http://displaytag.sourcefo
in the displaytag.zip that contained the jar file that you added to your WEB-INF/lib/ directory, there were some examples. Look at how they use css or create tables.
Business Accounts
Answer for Membership
by: kawasPosted on 2005-10-14 at 09:07:32ID: 15086623
what are you trying to do exactly? query a database?
F/lib directory you can replace:
y(sql) ;
It looks to me that one you download the library and place it in your webapps/serviceName/WEB-IN
<%
String sql = "Select ID,Name from employees" ;
ResultSet rs = beanconnection.executeQuer
%>
<%
while ( rs.next() ){
%>
A line of db stuff <%= rs.getString("Name") %>
<%
}
%>
with the new code