我使用dreamwear做的网上投票的例子其他的页面都调试的没有错误了 唯独主页面index.jsp出现了错误请各位帮帮我

解决方案 »

  1.   

    错误提示:
    exception org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:502)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:412)
    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: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:161)
    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:388)
    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: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
    sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
    sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
    sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(JdbcOdbc.java:3811)
    sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(JdbcOdbcResultSet.java:5638)
    sun.jdbc.odbc.JdbcOdbcResultSet.getInt(JdbcOdbcResultSet.java:583)
    sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1693)
    sun.jdbc.odbc.JdbcOdbcResultSet.getObject(JdbcOdbcResultSet.java:1743)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:128)
    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:388)
    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.33 logs.
      

  2.   

    源代码:
    <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="Connections/vote.jsp" %>
    <%
    Driver DriverrsVote = (Driver)Class.forName(MM_vote_DRIVER).newInstance();
    Connection ConnrsVote = DriverManager.getConnection(MM_vote_STRING,MM_vote_USERNAME,MM_vote_PASSWORD);
    PreparedStatement StatementrsVote = ConnrsVote.prepareStatement("SELECT * FROM vote");
    ResultSet rsVote = StatementrsVote.executeQuery();
    boolean rsVote_isEmpty = !rsVote.next();
    boolean rsVote_hasData = !rsVote_isEmpty;
    Object rsVote_data;
    int rsVote_numRows = 0;
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>网上投票系统首页</title>
    <style type="text/css">
    <!--
    .STYLE4 {
    font-family: "宋体";
    font-size: 16px;
    font-weight: bold;
    }
    -->
    </style>
    <script language="javascript">
    function doCheck(){
       var i;
       var n=0;
       for(i=0;i<form1.chkItem.length;i++)
         if(form1.chkItem[i].checked)n++;
       if(n==0){
         alert("至少要选择一项才能投票!");
         return false;
       }
    }
    </script>
    </head><body>
    <form id="form1" name="form1" method="post" action="servlet/vote" onsubmit="return doCheck()">
      <table width="278" border="1" align="center">
      <caption align="top">
        <span class="STYLE4">你最喜爱的旅游景点投票</span>
      </caption>
        <tr>
          <th width="88" scope="col">编号</th>
          <th width="174" scope="col">投票项目</th>
        </tr>
        <tr>
          <th scope="row"><%=(((rsVote_data = rsVote.getObject("id"))==null || rsVote.wasNull())?"":rsVote_data)%></th>
          <td><input name="chkItem" type="checkbox" id="chkItem" value="<%=rsVote_data %>" />
          <%=(((rsVote_data = rsVote.getObject("item"))==null || rsVote.wasNull())?"":rsVote_data)%></td>
        </tr>
      </table>
    </form>
    <form id="form2" name="form2" method="post" action="">
      <div align="center">
        <input name="btnVote" type="submit" id="btnVote" value="投票" />&nbsp;&nbsp;
        <input name="btnView" type="button" id="btnView" value="查看结果"  onclick="javascript:window.location='result.jsp'" />&nbsp;&nbsp;
        <input name="btnView" type="button" id="btnView" value="管理员登录"  onclick="javascript:window.location='login.jsp'" />
      </div>
    </form></body>
    </html>
    <%
    rsVote.close();
    StatementrsVote.close();
    ConnrsVote.close();
    %>
      

  3.   

    有的时候错误提示这个:
    在这句出错<th scope="row"><%=(((rsVote_data = rsVote.getObject("id"))==null || rsVote.wasNull())?"":rsVote_data)%></th>