Reputation: 3438
I am trying to use displaytag for the first time and having a problem with the displaytag, that i seems not be able to solve. I googled for solution, but couldn't find nothing over internet. Everything else is working it is the only thing thats not working.
Pretty much i am trying just do simple display of table.
the error i get is:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: org.apache.jasper.JasperException: Unable to load class for JSP
The JSP page is:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="dt" %>
<%--<jsp:useBean id="ForumList" scope="session" class="mysql.Forum" />--%>
<% session.setAttribute( "test2", mysql.Forum.getMyTopics() ); %>
<dt:table name="sessionScope.test2" />
and my class which is really simple one
package mysql;
import java.sql.*;
import java.sql.Connection;
import java.lang.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.jstl.sql.Result;
import javax.servlet.jsp.jstl.sql.ResultSupport;
public class Forum {
public Connection con = null;
public Result myTopics = null;
public MysqlBase mysql = new MysqlBase();
public Result getMyTopics()
{
try
{
con = mysql.getConnection();
Statement stmt = con.createStatement();
ResultSet result = stmt.executeQuery("Select * from lawers_topics");
myTopics = ResultSupport.toResult(result);
con.close();
stmt.close();
}
catch(Exception e)
{
}
//request.setAttribute("MyTopics", this.myTopics);
return this.myTopics;
}
}
I would really appreciate if somebody can point me in the right direction.
EDIT: I forgot to say that I use NetBeans and Tomcat6.0 for the development.
Upvotes: 1
Views: 1187
Reputation: 103145
try changing
<dt:table name="sessionScope.test2" />
to
<dt:table name="${test2}"/>
Upvotes: 1
Reputation: 19867
The error "Unable to load class for JSP" tells me that Tomcat isn't finding one or more of the class files you are referencing in the jsp. Are you sure that your mysql.Forum class is in the classpath (in this case, WEB-INF/classes/mysql/Forum.class)?
Additionally, it appears that you are trying to call getMyTopics() from your scriptlet as if it were a static method of the Forum class but it's not static.
Upvotes: 1
Reputation: 29576
Doesn't the object you're trying to display in the table have to implement java.util.List
?
Result
doesn't necessarily do that.
Upvotes: 1