严重: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 8 in the jsp file: /article.jsp
Unhandled exception type SQLException
5: private void tree(List<Article> articles,Connection conn, int id, int grade){
6: String sql = "select * from article where pid = "+id;
7: Statement stmt = DB.getstmt(conn);
8: ResultSet rs = stmt.executeQuery(sql);
9: try{
10: while(rs.next()){
11: Article a = new Article();
jsp源码:<%@ page pageEncoding="GB18030"%>
<%@ page import = "java.sql.*,com.yl.bbs.*,java.util.*" %><%!
private void tree(List<Article> articles,Connection conn, int id, int grade){
String sql = "select * from article where pid = "+id;
Statement stmt = DB.getstmt(conn);
ResultSet rs = stmt.executeQuery(sql);
try{
while(rs.next()){
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setRootId(rs.getInt("rootid"));
a.setTitle(rs.getString("title"));
a.setPdate(rs.getTimestamp("pdate"));
a.setIsleaf(rs.getInt("isleaf") == 0 ? true : false);
a.setGrade(grade);
articles.add(a);
if(!a.isIsleaf()){
tree(articles,conn,a.getId(),grade+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}
}
%><%
List<Article> articles = new ArrayList<Article>();
Connection conn = DB.getconn();
tree(articles,conn,0,0);
DB.close(conn);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Java语言*初级版</title>
<meta http-equiv="content-type" content="text/html; charset=utf8">
<link rel="stylesheet" type="text/css" href="images/style.css" title="Integrated Styles">
<script language="JavaScript" type="text/javascript" src="images/global.js"></script>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://bbs.chinajavaworld.com/rss/rssmessages.jspa?forumID=20">
<script language="JavaScript" type="text/javascript" src="images/common.js"></script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="40%"><br>av<img src="images/header-stretch.gif" alt="" border="0" height="57" width="100%">
</td>
<td width="1%"><img src="images/header-right.gif" alt="" height="57" border="0"></td>
</tr>
</tbody>
</table>
<br>
<div id="jive-forumpage">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="98%"><p class="jive-breadcrumbs">论坛: Java语言*初级版
(模仿)</p>
<p class="jive-description"> 探讨Java语言基础知识,基本语法等 大家一起交流 共同提高!谢绝任何形式的广告 </p>
</td>
</tr>
</tbody>
</table>
<div class="jive-buttons">
<table summary="Buttons" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="jive-icon"><a href="post.jsp"><img src="images/post-16x16.gif" alt="发表新主题" border="0" height="16" width="16"></a></td>
<td class="jive-icon-label"><a id="jive-post-thread" href="post.jsp">发表新主题</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&isBest=1"></a></td>
</tr>
</tbody>
</table>
</div>
<br>
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td><span class="nobreak"> 页:
1,316 - <span class="jive-paginator"> [ <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=0&isBest=0">上一页</a> | <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=0&isBest=0" class="">1</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=25&isBest=0" class="jive-current">2</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=50&isBest=0" class="">3</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=75&isBest=0" class="">4</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=100&isBest=0" class="">5</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=125&isBest=0" class="">6</a> | <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=50&isBest=0">下一页</a> ] </span> </span> </td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="99%"><div class="jive-thread-list">
<div class="jive-table">
<table summary="List of threads" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th class="jive-first" colspan="3"> 主题 </th>
<th class="jive-author"> <nobr> 作者
</nobr> </th>
<th class="jive-view-count"> <nobr> 浏览
</nobr> </th>
<th class="jive-msg-count" nowrap="nowrap"> 回复 </th>
<th class="jive-last" nowrap="nowrap"> 最新帖子 </th>
</tr>
</thead>
<tbody>
<%
for(Iterator<Article> it = articles.iterator();it.hasNext();){
Article a = it.next();
%>
<tr class="jive-even">
<td class="jive-first" nowrap="nowrap" width="1%"><div class="jive-bullet"> <img src="images/read-16x16.gif" alt="已读" border="0" height="16" width="16">
<!-- div-->
</div></td>
<td nowrap="nowrap" width="1%">=
</td>
<td class="jive-thread-name" width="95%">rt</td>
<td class="jive-author" nowrap="nowrap" width="1%"><span class=""> <a href="http://bbs.chinajavaworld.com/profile.jspa?userID=226030">bjsxt</a> </span></td>
<td class="jive-view-count" width="1%"> 10000</td>
<td class="jive-msg-count" width="1%"> 0</td>
<td class="jive-last" nowrap="nowrap" width="1%"><div class="jive-last-post"> <br>
by: <a href="http://bbs.chinajavaworld.com/thread.jspa?messageID=780182#780182" title="jingjiangjun" style="">bjsxt »</a> </div></td>
</tr>
<tr class="jive-odd">
<td class="jive-first" nowrap="nowrap" width="1%"><div class="jive-bullet"> <img src="images/read-16x16.gif" alt="已读" border="0" height="16" width="16">
<!-- div-->
</div></td>
<td nowrap="nowrap" width="1%">
</td>
<td class="jive-thread-name" width="95%"><a id="jive-thread-2" href="http://bbs.chinajavaworld.com/thread.jspa?threadID=744234&tstart=25">请 兄弟们指点下那里 错误,,,</a></td>
<td class="jive-author" nowrap="nowrap" width="1%"><span class=""> <a href="http://bbs.chinajavaworld.com/profile.jspa?userID=226028">403783154</a> </span></td>
<td class="jive-view-count" width="1%"> 52</td>
<td class="jive-msg-count" width="1%"> 2</td>
<td class="jive-last" nowrap="nowrap" width="1%"><div class="jive-last-post"> 2007-9-13 上午8:40 <br>
by: <a href="http://bbs.chinajavaworld.com/thread.jspa?messageID=780172#780172" title="downing114" style="">downing114 »</a> </div></td>
</tr> <%
}
%>
</tbody>
</table>
</div>
</div>
<div class="jive-legend"></div></td>
</tr>
</tbody>
</table>
<br>
<br>
</div>
</body>
</html>
org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 8 in the jsp file: /article.jsp
Unhandled exception type SQLException
5: private void tree(List<Article> articles,Connection conn, int id, int grade){
6: String sql = "select * from article where pid = "+id;
7: Statement stmt = DB.getstmt(conn);
8: ResultSet rs = stmt.executeQuery(sql);
9: try{
10: while(rs.next()){
11: Article a = new Article();
jsp源码:<%@ page pageEncoding="GB18030"%>
<%@ page import = "java.sql.*,com.yl.bbs.*,java.util.*" %><%!
private void tree(List<Article> articles,Connection conn, int id, int grade){
String sql = "select * from article where pid = "+id;
Statement stmt = DB.getstmt(conn);
ResultSet rs = stmt.executeQuery(sql);
try{
while(rs.next()){
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setRootId(rs.getInt("rootid"));
a.setTitle(rs.getString("title"));
a.setPdate(rs.getTimestamp("pdate"));
a.setIsleaf(rs.getInt("isleaf") == 0 ? true : false);
a.setGrade(grade);
articles.add(a);
if(!a.isIsleaf()){
tree(articles,conn,a.getId(),grade+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}
}
%><%
List<Article> articles = new ArrayList<Article>();
Connection conn = DB.getconn();
tree(articles,conn,0,0);
DB.close(conn);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Java语言*初级版</title>
<meta http-equiv="content-type" content="text/html; charset=utf8">
<link rel="stylesheet" type="text/css" href="images/style.css" title="Integrated Styles">
<script language="JavaScript" type="text/javascript" src="images/global.js"></script>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://bbs.chinajavaworld.com/rss/rssmessages.jspa?forumID=20">
<script language="JavaScript" type="text/javascript" src="images/common.js"></script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td width="40%"><br>av<img src="images/header-stretch.gif" alt="" border="0" height="57" width="100%">
</td>
<td width="1%"><img src="images/header-right.gif" alt="" height="57" border="0"></td>
</tr>
</tbody>
</table>
<br>
<div id="jive-forumpage">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="98%"><p class="jive-breadcrumbs">论坛: Java语言*初级版
(模仿)</p>
<p class="jive-description"> 探讨Java语言基础知识,基本语法等 大家一起交流 共同提高!谢绝任何形式的广告 </p>
</td>
</tr>
</tbody>
</table>
<div class="jive-buttons">
<table summary="Buttons" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="jive-icon"><a href="post.jsp"><img src="images/post-16x16.gif" alt="发表新主题" border="0" height="16" width="16"></a></td>
<td class="jive-icon-label"><a id="jive-post-thread" href="post.jsp">发表新主题</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&isBest=1"></a></td>
</tr>
</tbody>
</table>
</div>
<br>
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td><span class="nobreak"> 页:
1,316 - <span class="jive-paginator"> [ <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=0&isBest=0">上一页</a> | <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=0&isBest=0" class="">1</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=25&isBest=0" class="jive-current">2</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=50&isBest=0" class="">3</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=75&isBest=0" class="">4</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=100&isBest=0" class="">5</a> <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=125&isBest=0" class="">6</a> | <a href="http://bbs.chinajavaworld.com/forum.jspa?forumID=20&start=50&isBest=0">下一页</a> ] </span> </span> </td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr valign="top">
<td width="99%"><div class="jive-thread-list">
<div class="jive-table">
<table summary="List of threads" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th class="jive-first" colspan="3"> 主题 </th>
<th class="jive-author"> <nobr> 作者
</nobr> </th>
<th class="jive-view-count"> <nobr> 浏览
</nobr> </th>
<th class="jive-msg-count" nowrap="nowrap"> 回复 </th>
<th class="jive-last" nowrap="nowrap"> 最新帖子 </th>
</tr>
</thead>
<tbody>
<%
for(Iterator<Article> it = articles.iterator();it.hasNext();){
Article a = it.next();
%>
<tr class="jive-even">
<td class="jive-first" nowrap="nowrap" width="1%"><div class="jive-bullet"> <img src="images/read-16x16.gif" alt="已读" border="0" height="16" width="16">
<!-- div-->
</div></td>
<td nowrap="nowrap" width="1%">=
</td>
<td class="jive-thread-name" width="95%">rt</td>
<td class="jive-author" nowrap="nowrap" width="1%"><span class=""> <a href="http://bbs.chinajavaworld.com/profile.jspa?userID=226030">bjsxt</a> </span></td>
<td class="jive-view-count" width="1%"> 10000</td>
<td class="jive-msg-count" width="1%"> 0</td>
<td class="jive-last" nowrap="nowrap" width="1%"><div class="jive-last-post"> <br>
by: <a href="http://bbs.chinajavaworld.com/thread.jspa?messageID=780182#780182" title="jingjiangjun" style="">bjsxt »</a> </div></td>
</tr>
<tr class="jive-odd">
<td class="jive-first" nowrap="nowrap" width="1%"><div class="jive-bullet"> <img src="images/read-16x16.gif" alt="已读" border="0" height="16" width="16">
<!-- div-->
</div></td>
<td nowrap="nowrap" width="1%">
</td>
<td class="jive-thread-name" width="95%"><a id="jive-thread-2" href="http://bbs.chinajavaworld.com/thread.jspa?threadID=744234&tstart=25">请 兄弟们指点下那里 错误,,,</a></td>
<td class="jive-author" nowrap="nowrap" width="1%"><span class=""> <a href="http://bbs.chinajavaworld.com/profile.jspa?userID=226028">403783154</a> </span></td>
<td class="jive-view-count" width="1%"> 52</td>
<td class="jive-msg-count" width="1%"> 2</td>
<td class="jive-last" nowrap="nowrap" width="1%"><div class="jive-last-post"> 2007-9-13 上午8:40 <br>
by: <a href="http://bbs.chinajavaworld.com/thread.jspa?messageID=780172#780172" title="downing114" style="">downing114 »</a> </div></td>
</tr> <%
}
%>
</tbody>
</table>
</div>
</div>
<div class="jive-legend"></div></td>
</tr>
</tbody>
</table>
<br>
<br>
</div>
</body>
</html>
解决方案 »
- 使用hibernate.sessionfactory时插入多条语句时,直插入了最后一天语句,前面的都被覆盖了。怎么回事?
- 小菜、求一个c3p0连接池的、教程 谢谢了、在线等
- 关于cookie被停用的问题。高分在先求教
- 有一组变量,想用xslt把它的值赋给给xml里的变量,然后生成新的xml
- 项目合作 web 2.0
- ext linechart 横坐标是时间轴,怎么加事件可是使时间变成时分格式呢
- 一个tomcat使用的初级问题
- 救急!!!include
- jsp中Date变量如何处理???
- JSP网站开发的问题!非常着急!
- 简单的JSP标记问题~~新手~~求解
- 引用了外部的SDK,javac编译总是报“找不到符号”
ResultSet rs = stmt.executeQuery(sql);
这两句话,放到try模块里它们也会抛SQLException的。
An error occurred at line: 8 in the jsp file: /article.jsp
应该是数据库查询的问题。