码迷,mamicode.com
首页 > Web开发 > 详细

jsp大学课程hi实验:分页在线测评(session的使用)

时间:2018-05-03 23:26:28      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:content   重置   style   attr   radio   sub   equal   amp   传递   

project_1_updata_1_1.jsp
 1 <%@ page contentType="text/html;charset=utf-8" language="java" %>
 2 <html>
 3 <head>
 4     <title>project_1</title>
 5 </head>
 6 <body>
 7 <form action="project_1_updata_1_2.jsp" method="post" name="form1">
 8     单选题<br>
 9     1.application对象所依赖的类或接口是(15`)<br>
10     <input type="radio" name="t1" value="A">A、JspWrite<br>
11     <input type="radio" name="t1" value="B">B、ServletContext<br>
12     <input type="radio" name="t1" value="C">C、PageContext<br>
13     <input type="radio" name="t1" value="D">D、HttpServletContext<br>
14     2.下面说法错误的是(15`)<br>
15     <input type="radio" name="t2" value="A">A、要在JSP网页内直接嵌入一段Java代码,这段代码可以写在script标记对内<br>
16     <input type="radio" name="t2" value="B">B、要在JSP网页内直接嵌入一段Java代码,可以写在标记内<br>
17     <input type="radio" name="t2" value="C">C、JSP代码中变量和方法的声明是写在标记内<br>
18     <input type="radio" name="t2" value="D">D、以上说法都正确<br>
19     <input type="submit" value="下一页" name="submit">
20     <input type="reset" value="重置"><br>
21 
22 </form>
23 </body>
24 </html>
project_1_updata_1_2.jsp
 1 <%@ page contentType="text/html;charset=utf-8" language="java" %>
 2 <html>
 3 <head>
 4     <title>project_1</title>
 5 </head>
 6 <body>
 7 <%!
 8     String t1 = "";
 9     String t2 = "";
10 %>
11 <%
12     t1 = request.getParameter("t1");
13     session.putValue("t1", t1);
14     t2 = request.getParameter("t2");
15     session.putValue("t2", t2);
16 %>
17 <form action="project_1_updata_1_3.jsp" method="post" name="form1">
18     多选题<br>
19     3.下面关于session的用法哪个不是正确的?(20`)<br>
20     <input type="checkbox" name="t3" value="A">A、HttpSession session = new HttpSession()<br>
21     <input type="checkbox" name="t3" value="B">B、String haha =session.getParameter(“haha”)<br>
22     <input type="checkbox" name="t3" value="C">C、session.removeAttribute(“haha”)<br>
23     <input type="checkbox" name="t3" value="D">D、session. setAttribute(“haha”)<br>
24     4.以下关于HTML表单的叙述正确的是(20`)<br>
25     <input type="checkbox" name="t4" value="A">A、表单按钮和表单文本框的标记都是用input标记定义<br>
26     <input type="checkbox" name="t4" value="B">B、GET表单提交方式较POST方式快速//速度:显然Get比Post要快。<br>
27     <input type="checkbox" name="t4" value="C">C、POST表单提交方式把数据链接在目标资源的URL中,而GET方式把表 单数据存储在HTTP请求报头的尾部<br>
28     <input type="checkbox" name="t4" value="D">D、同名复选框可向服务器传递0个或多个数据值,而同名单选按钮只能向 服务器传递1个数据值。<br>
29     <input type="submit" value="下一页" name="submit">
30     <input type="reset" value="重置">
31 </form>
32 </body>
33 </html>
project_1_updata_1_3.jsp
 1 <%@ page contentType="text/html;charset=utf-8" language="java" %>
 2 <html>
 3 <head>
 4     <title>project_1</title>
 5 </head>
 6 <body>
 7 <%!
 8     String []t3;
 9     String []t4;
10 %>
11 <%
12     String t1 = (String) session.getValue("t1");
13     session.putValue("t1",t1);
14     String t2 = (String) session.getValue("t2");
15     session.putValue("t2",t2);
16     t3 = request.getParameterValues("t3");
17     session.setAttribute("t3",t3);
18     t4 = request.getParameterValues("t4");
19     session.setAttribute("t4",t4);
20 %>
21 <form action="project_1_updata_2.jsp" method="post" name="form1">
22     5.(1)jsp:forward动作用来把当前的JSP页面重导到另一个页面上,用户看到的地址是当前页面的地址,而内容是另一个页面的。(15`)<br>
23     <input type="radio" name="t5" value="true"><br>
24     <input type="radio" name="t5" value="false"><br>
25     (2)jsp:param动作可单独使用,用于页面间传递参数。(15`)<br>
26     <input type="radio" name="t6" value="true"><br>
27     <input type="radio" name="t6" value="false"><br>
28     <input type="submit" value="提交" name="submit">
29     <input type="reset" value="重置">
30 </form>
31 </body>
32 </html>
project_1_updata_2.jsp
  1 <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2 <html>
  3 <head>
  4     <title>得分情况</title>
  5 </head>
  6 <body>
  7 <%!
  8     int sum = 0;//总分
  9     String t5 = "";
 10     String t6 = "";
 11 %>
 12 <%
 13     String t1 = (String) session.getValue("t1");
 14     String t2 = (String) session.getValue("t2");
 15     String [] t3 = (String[]) session.getAttribute("t3");
 16     String [] t4 = (String[]) session.getAttribute("t4");
 17     t5 = request.getParameter("t5");
 18     t6 = request.getParameter("t6");
 19 
 20 
 21 //    String t1 = request.getParameter("t1");
 22 //    String t2 = request.getParameter("t2");
 23 //    String t3[] = request.getParameterValues("t3");
 24 //    String t4[] = request.getParameterValues("t4");
 25 //    String t5 = request.getParameter("t5");
 26 //    String t6 = request.getParameter("t6");
 27 
 28     //说明答案
 29     out.print("第一题答案为B,你选择的答案为" + t1);
 30     if (t1 == null) {
 31         out.print("\t回答错误不得分");
 32     } else if (t1.equals("B")) {
 33         sum = sum + 15;
 34         out.print("\t得分:15分");
 35     } else {
 36         out.print("\t回答错误不得分");
 37     }
 38 %><br><%
 39     out.print("第二题答案为A,你选择的答案为" + t2);
 40     if (t2 == null) {
 41         out.print("\t回答错误不得分");
 42     } else if (t2.equals("A")) {
 43         sum = sum + 15;
 44         out.print("\t得分:15分");
 45     } else {
 46         out.print("\t回答错误不得分");
 47     }
 48 %><br><%
 49     out.print("第三题答案为ABD,你选择的答案为");
 50     if (t3 == null) {
 51         out.print("null\t回答错误不得分");
 52     }else {
 53         for (String s : t3) {
 54             out.print(s);
 55         }
 56         if (t3.length == 1 || t3.length == 2 || t3.length == 4) {
 57             out.print("\t回答错误不得分");
 58         } else if (t3.length == 3) {
 59             if (t3[0].equals("A") && t3[1].equals("B") && t3[2].equals("D")) {
 60                 sum = sum + 20;
 61                 out.print("\t得分:20分");
 62             } else {
 63                 out.print("\t回答错误不得分");
 64             }
 65         } else {
 66             out.print("\t回答错误不得分");
 67         }
 68     }
 69 %><br><%
 70     out.print("第四题答案为ACD,你选择的答案为");
 71     if (t4 == null) {
 72         out.print("null\t回答错误不得分");
 73     }else {
 74         for (String s : t4) {
 75             out.print(s);
 76         }
 77         if (t3.length == 1 || t3.length == 2 || t3.length == 4) {
 78             out.print("\t回答错误不得分");
 79         } else if (t3.length == 3) {
 80             if (t4[0].equals("A") && t4[1].equals("C") && t4[2].equals("D")) {
 81                 sum = sum + 20;
 82                 out.print("\t得分:20分");
 83             } else {
 84                 out.print("\t回答错误不得分");
 85             }
 86         }
 87     }
 88 %><br><%
 89     out.print("第五题答案为false,你选择的答案为" + t5);
 90     if (t1 == null) {
 91         out.print("\t回答错误不得分");
 92     } else if (t5.equals("false")) {
 93         sum = sum + 15;
 94         out.print("\t得分:15分");
 95     } else {
 96         out.print("\t回答错误不得分");
 97     }
 98 %><br><%
 99     out.print("第六题答案为false,你选择的答案为" + t5);
100     if (t1 == null) {
101         out.print("\t回答错误不得分");
102     } else if (t6.equals("true")) {
103         sum = sum + 15;
104         out.print("\t得分:15分");
105     } else {
106         out.print("\t回答错误不得分");
107     }
108 %><br><%
109     out.print("总分为" + sum);
110 %>
111 </body>
112 </html>

 

 

jsp大学课程hi实验:分页在线测评(session的使用)

标签:content   重置   style   attr   radio   sub   equal   amp   传递   

原文地址:https://www.cnblogs.com/lgqrlchinese/p/8987929.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!