JSP编译出现异常,求解答。

typeExceptionreportmessagedescriptionTheserverencounteredaninternalerror()thatprevent... type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /ShowArticleTree.jsp at line 49

46:
47: Statement stmt = conn.createStatement();
48: ResultSet rs = stmt.executeQuery("select * from article where pid= 0");
49: while(rs.next()){
50: str+="<tr><td>"+ rs.getInt("id")+"</td><td>"+
51: rs.getString("cont") +"</td></tr>";
52: if(rs.getInt("isleaf")!=0){

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

javax.servlet.ServletException: java.sql.SQLException: Operation not allowed after ResultSet closed
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:143)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

java.sql.SQLException: Operation not allowed after ResultSet closed
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:794)
com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7145)
org.apache.jsp.ShowArticleTree_jsp._jspService(ShowArticleTree_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.
while循环里其实就只剩下一个方法了,我把方法贴出来。
if(rs.getInt("isleaf")!=0){
tree(conn,rs.getInt("id"),1);
}
private void tree(Connection conn,int id,int level){
Statement stmt = null;
ResultSet rs = null;
String preStr = "";
for(int i=0;i<level;i++){
preStr += "----";
}
try{
stmt = conn.createStatement();
String sql = "select * from article where pid = "+id;
rs = stmt.executeQuery(sql);
while(rs.next()){
str +="<tr><td>"+ rs.getInt("id")+"</td><td>"+
preStr +rs.getString("title") +"</td></tr>";
if(rs.getInt("cont")!=0){
tree(conn,rs.getInt("id"),level+1);
}
}
}catch(SQLException e){
e.printStackTrace();
}finally{try{if(rs !=null){rs.close();rs = null;}if(stmt !=null){stmt.close();
stmt = null;
}
}catch (SQLException e){
e.printStackTrace();
展开
 我来答
wujiazhao1988
2011-02-25 · TA获得超过413个赞
知道小有建树答主
回答量:397
采纳率:0%
帮助的人:305万
展开全部
估计你在while里边关闭了rs, 你把while整段贴出来看看啊.
java.sql.SQLException: Operation not allowed after ResultSet closed
这是主要异常.
追问
1
家有小多多
2011-02-25 · TA获得超过467个赞
知道答主
回答量:421
采纳率:0%
帮助的人:0
展开全部
"text/html; charset=UTF-8" language="java" %>

然后用记事本打开该jsp文件,另存为,选择编码为UTF-8。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友91f49c4
2011-02-26 · TA获得超过1176个赞
知道小有建树答主
回答量:1683
采纳率:0%
帮助的人:677万
展开全部
把while整段代码贴出来看看
追问
补全了,请再帮我看看。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
积木时代
2011-02-25 · TA获得超过586个赞
知道小有建树答主
回答量:1055
采纳率:33%
帮助的人:338万
展开全部
听 wujiazhao1988 的把, 另外补全下那断代码.
追问
补全了,请再帮我看看。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式