JSP网页代码错误
我的代码<%@pagecontentType="text/html;charset=gb2312"import="java.sql.*"%><jsp:useBeanid=...
我的代码
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="db" property="connStr" value="jdbc:odbc:vote"/>
<html><body>
<center>
<h2>您最喜爱的奥斯卡获奖影片是:</h2>
<table border bordercolor="#0066FF" bgcolor="#CCFFFF">
<form method="post" action="vote.jsp">
<%
ResultSet rs=db.executeQuery("select * from vote");
while(rs.next())
{
out.println("<tr>");
out.println("<td><input type='radio' name='id' value='"+rs.getString("id")+"'>");
out.println(rs.getString("item"));
out.println("</td>");
}
rs.close();
db.close();
session.setMaxInactiveInterval(-1);
%>
<tr><td align="center"><input type="submit" value="投票"></td>
</form>
<tr><td align="center"><a href="info.jsp">查看投票</a></td>
</table>
<p><a href="manage.jsp">投票系统维护</a>
</center>
</body></html>
但运行时报错说
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 /index.jsp at line 11
8: <form method="post" action="vote.jsp">
9: <%
10: ResultSet rs=db.executeQuery("select * from vote");
11: while(rs.next())
12: {
13: out.println("<tr>");
14: out.println("<td><input type='radio' name='id' value='"+rs.getString("id")+"'>");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
请问怎么解决 我其他网页基本都是这个rs.next()哪里报错 展开
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="db" property="connStr" value="jdbc:odbc:vote"/>
<html><body>
<center>
<h2>您最喜爱的奥斯卡获奖影片是:</h2>
<table border bordercolor="#0066FF" bgcolor="#CCFFFF">
<form method="post" action="vote.jsp">
<%
ResultSet rs=db.executeQuery("select * from vote");
while(rs.next())
{
out.println("<tr>");
out.println("<td><input type='radio' name='id' value='"+rs.getString("id")+"'>");
out.println(rs.getString("item"));
out.println("</td>");
}
rs.close();
db.close();
session.setMaxInactiveInterval(-1);
%>
<tr><td align="center"><input type="submit" value="投票"></td>
</form>
<tr><td align="center"><a href="info.jsp">查看投票</a></td>
</table>
<p><a href="manage.jsp">投票系统维护</a>
</center>
</body></html>
但运行时报错说
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 /index.jsp at line 11
8: <form method="post" action="vote.jsp">
9: <%
10: ResultSet rs=db.executeQuery("select * from vote");
11: while(rs.next())
12: {
13: out.println("<tr>");
14: out.println("<td><input type='radio' name='id' value='"+rs.getString("id")+"'>");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
请问怎么解决 我其他网页基本都是这个rs.next()哪里报错 展开
4个回答
展开全部
11行报的错 是不是你结果集 db是不是获得正确啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这个代码没有错,我给你运行了下!可以运行!你把这个代码复制到Macromedia Dreamweaver 里的代码中,按下拆分 就能看到运行结果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
会不会没数据库驱动?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询