⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 answer.jsp

📁 自己做的一份在线考试系统
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" import="java.sql.*" errorPage="errorpage.jsp" %>
<%@ page import="java.sql.*" %>
<jsp:useBean id="getAnswer" scope="page" class="BeanPage.loginBean"/>
<%--在同一个jsp页面里可以同时使用上面的语句--%>
<html>
<head>
<title>答题结果</title>
<style type="text/css">
<!--
.STYLE1 {
	font-size: xx-large;
	font-weight: bold;
	color: #FF0000;
}
.STYLE2 {
	color: #0000FF;
	font-size: x-large;
	font-weight: bold;
}
.STYLE3 {
	font-size: large;
	font-weight: bold;
}
.STYLE4 {color: #0000FF}
#Layer1 {
	position:absolute;
	width:731px;
	height:300px;
	z-index:1;
	left: 97px;
	top: 245px;
}
.STYLE5 {color: #FF6600}
.STYLE6 {color: #99CC33; font-size: x-large; font-weight: bold; }
.STYLE7 {color: #660033}
-->
</style>
</head>
<body>
<img src="images/2006110909323034351.jpg" width="1024" height="768">
<div id="Layer1">
  <p align="center" class="STYLE1 STYLE5">测试已结束</p>
  <p align="center" class="STYLE1 STYLE4">&nbsp;</p>
  <p align="center" class="STYLE6"> 恭喜你&nbsp;&nbsp;&nbsp; 你答对了
    <% 
        int rown=3;
        String studentName = (String)session.getAttribute("stuName");
        byte  name[] = studentName.getBytes("ISO-8859-1");
        studentName = new String(name);
        String studentNum = (String)session.getAttribute("stuNum");
        String subject = request.getParameter("subjectN");
        ResultSet RS_result = getAnswer.executeQuery("select * from "+request.getParameter("subjectN"));
        String radioN;
        int n=0;
        String answer;
        while(RS_result.next())
            {
                answer = RS_result.getString("correct");
                String s1 = request.getParameter(RS_result.getString("radio"));
                if(s1==null)
                    {s1="";}
                if(s1.equals(answer))
                    {n++;}
            }
         out.print(n);
         %>
    道题!</p>
  <p align="center" class="STYLE2">&nbsp;</p>
  <p align="center">
    <%//修改数据库中的分数
         int score = n*10;
         String scores = Integer.toString(score);
         String studentNu = (String)session.getAttribute("stuNum");
         String updateScore = "UPDATE stuScore SET "+request.getParameter("subjectN")+"='"+scores+"' WHERE stuNum ='"+studentNu+"'";
         Connection con;
         Statement sql; 
         ResultSet rs;
         try{  
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            }catch(ClassNotFoundException e){}
        try {  
           con=DriverManager.getConnection("jdbc:odbc:login");
           sql=con.createStatement();
           sql.executeUpdate(updateScore);
           con.close();
           }catch(SQLException e){  
               out.println(e);
           }
     %>
    <input name="button"   type=button   onClick=window.history.go(-2)   value=退回选科>
  </p>
  <p align="center">&nbsp;</p>
  <p align="center" class="STYLE7"><a href="main.jsp" target="_self" class="STYLE3">退出系统</a></p>
  <p class="STYLE7">&nbsp; </p>
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -