questionsavemodify.jsp
上传用户:hjt198082
上传日期:2015-04-16
资源大小:95k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

Java

  1. <%@page contentType="text/html;charset=GBK"%>
  2. <%@page import="java.sql.*" errorPage="/public/error.jsp"%>
  3. <%@ include file="/public/checkvalidadmin.jsp"%>
  4. <%@ include file="/public/checkvalidadmin8.jsp"%>
  5. <jsp:useBean id="conn" scope="page" class="test.ConnOracle"/>
  6. <%!
  7. ResultSet rs = null;
  8. String questionid;
  9. String selectid;
  10. String classid;
  11. String qname;
  12. String choice1;
  13. String choice2;
  14. String choice3;
  15. String choice4;
  16. String answer;
  17. String sql = "";
  18. int result = 0;
  19. String currpage = "1";
  20. %>
  21. <%
  22. request.setCharacterEncoding("GBK");
  23. currpage   = request.getParameter("Page");
  24. questionid = request.getParameter("questionid");
  25. selectid = request.getParameter("selectid");
  26. classid = request.getParameter("classid");
  27. qname = request.getParameter("qname");
  28. choice1 = request.getParameter("choice1");
  29. choice2 = request.getParameter("choice2");
  30. choice3 = request.getParameter("choice3");
  31. choice4 = request.getParameter("choice4");
  32. answer = request.getParameter("answer");
  33. // 避免用户直接在浏览器地址栏输入页面地址所产生的Exception
  34. if(questionid==null || questionid.equals("")) {
  35.     out.println("<center>");
  36. out.println("请进行合法操作!");
  37. out.println("</center>");
  38. return;
  39. }
  40. try{
  41. sql  = "select * from test_question_lib where ";
  42. sql += " questionid='" + questionid + "'";
  43. rs = conn.executeQuery( sql );
  44. if(!rs.next()) {
  45. out.println("<center>");
  46. out.println("数据库没有代号为" + questionid + "的试题信息!<br>");
  47. out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
  48. out.println("</center>");
  49. } else {
  50. sql = "update test_question_lib set selectid=" + selectid;
  51. sql+= ",classid='" + classid + "'";
  52. sql+= ",qname='" + qname + "'";
  53. sql+= ",choice1='" + choice1 + "'";
  54. sql+= ",choice2='" + choice2 + "'";
  55. sql+= ",choice3='" + choice3 + "'";
  56. sql+= ",choice4='" + choice4 + "'";
  57. sql+= ",answer='"  + answer + "'";
  58. sql+= " where questionid='" + questionid + "'";
  59. result = conn.executeUpdate( sql );
  60. if(result !=1 ) {
  61. out.println("<center>");
  62. out.println("试题信息更新失败!<br><br>");
  63. out.println("请将下列信息告知管理员<br><br>");
  64. out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
  65. out.println("</center>");
  66. }
  67. }
  68. }catch(Exception ee) {
  69. out.println("<center>");
  70. out.println("试题信息更新失败!<br><br>");
  71. out.println("请将下列信息告知管理员<br><br>");
  72. out.println(ee.toString() + "<br><br>");
  73. out.println("单击这里<a href=javascript:history.back()>返回</a><br>");
  74. out.println("</center>");
  75. }
  76. %>
  77. <jsp:forward page="questionmanager.jsp">
  78.    <jsp:param name="Page" value="<%=currpage%>"/>
  79. </jsp:forward>
  80. </center>
  81. </Body>
  82. </html>