java代码:
package vote;
import java.sql.*;
public class vote_conn{
String sdbdriver="sun.jdbc.odbc.JdbcOdbcDriver";
String sconnstr="jdbc:odbc:vote";
Connection connect=null;
ResultSet rs=null;
public vote_conn(){
try{
Class.forName(sdbdriver);
}catch(java.lang.ClassNotFoundException e){System.err.println(e.getMessage());
}
}
public ResultSet executeQuery(String sql){
try{
connect=DriverManager.getConnection(sconnstr,"","");
Statement stmt=connect.createStatement();
rs=stmt.executeQuery(sql);
}catch(SQLException ex){System.err.println(ex.getMessage());
}
return rs;
}
public int executeUpdate(String sql){
int result=0;
try{
connect=DriverManager.getConnection(sconnstr);
Statement stmt=connect.createStatement();
result=stmt.executeUpdate(sql);
}catch(SQLException ex){System.err.println(ex.getMessage());
}
return result;
} }
jsp代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="conndbbean" scope="page" class="vote.vote_conn" />
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>网上调查</title>
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
<!--
.STYLE1 {color: #0000ff}
.STYLE2 {font-size: 14px}
-->
</style>
</head>
<%
ResultSet rs=conndbbean.executeQuery("select * from vote");
%>
<body>
<div align="center" class="STYLE1">请您投票</div>
<form action="vote.jsp">
<%
while(rs.next()){
%>
<tr>
<td><input type="radio" name="type" value=<%=rs.getString("id")%> ><%=rs.getString("note")%></td>
</tr>
<%}
rs.close();%>
<tr align="center"><td> <input type="submit" name="Submit" value="投票" ></td></tr>
</form>
<p>查看投票</p>
</body>
</html>
错误:
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /vote/index.jsp:23
20: <div align="center" class="STYLE1">请您投票</div>
21: <form action="vote.jsp">
22: <%
23: while(rs.next()){
24: %>
25: <tr>
26: <td><input type="radio" name="type" value=<%=rs.getString("id")%> ><%=rs.getString("note")%></td>
请大家帮我看看啊
谢谢了!
我的配置是tomcat5.5.17+jdk1.5
为什么我网上下的每个代码都出现while的问题
org.apache.jasper.JasperException: Exception in JSP: /index.jsp:65
62: </tr>
63: <%
64: String sql="select * from 论坛";
65: ResultSet rs=odbc.executeQuery(sql);
66: while(rs.next()){
67: %>
68: <tr bgcolor="#D1EBF1">
为什么啊
[此贴子已经被作者于2006-7-9 23:30:31编辑过]