thanks.jsp
上传用户:apbaoyuan
上传日期:2021-02-12
资源大小:1015k
文件大小:1k
源码类别:

Jsp/Servlet

开发平台:

HTML/CSS

  1. <%@page import="java.sql.*"%>
  2. <%@page import="java.util.*"%>
  3. <%@page contentType="text/html;charset=GB2312"%>
  4. <%@include file="opendata.jsp"%>
  5. <%@include file="convert.jsp"%>
  6. <html>
  7. <head>
  8. <title>
  9. 投票提交处理
  10. </title>
  11. <LINK href="style.css" rel=stylesheet>
  12. </head>
  13. <body>
  14. <%
  15. try {request.setCharacterEncoding("GB2312");
  16.   sql = "SELECT QuestionID from Questions where IsVisable = 1 ";
  17.   rs = smt.executeQuery(sql);
  18.   String question = null,item = null;
  19.   int questionid = 0;
  20.   int itemid1;
  21.    Statement _smt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  22.    Statement _smt_=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  23.   while(rs.next())
  24.   { String[] vote=null;
  25.     questionid = rs.getInt(1);
  26.     vote=request.getParameterValues(String.valueOf(questionid));
  27.     if(vote!=null)
  28.      {
  29.         
  30.      sql = "update Questions set QuestionCount = QuestionCount + 1  Where QuestionId ="+questionid;
  31.          _smt .executeUpdate(sql);
  32.         for(int i=0;i<vote.length;i++)
  33.          {   
  34.             sql = "update Items set ItemCount = ItemCount + 1  Where ItemID ="+Integer.parseInt(vote[i]);
  35.              _smt_.executeUpdate(sql);
  36.            
  37.          }
  38.          //_smt_.close();
  39.      }
  40.     
  41.     }
  42.       //rs.close();
  43.      
  44.  
  45.  }
  46.   
  47. catch (Exception e) {
  48. e.getStackTrace();
  49. }
  50.  //smt.close();
  51.  //con.close();
  52.  response.sendRedirect("showquestion.jsp");
  53.  
  54. %>
  55. </body>
  56. </html>