1 yang.html
2 <html>
3 <title>第二题1</title>
4 <body bgcolor=cyan>
5 <font size=20 color=red>
6 <form action="receive.jsp" method=post name=form>
7 个人信息页面:<br>
8 姓名:<input type=text name="name" value=""><br>
9 密码:<input type=password name="password"><br>
10 性别:<input type=radio name="sex" value="男" > 男
11 <input type=radio name="sex" value="女">女 <br>
12 班级:<input type=radio name="Class" value="Java 1">java1
13 <input type=radio name="Class" value="Java 2">java2
14 <input type=radio name="Class" value="Java 3">java3
15 <input type=radio name="Class" value="Java 4">java4<br>
16 爱好:<input type=checkbox name="hobby" value="学习">学习
17 <input type=checkbox name="hobby" value="聊天">聊天
18 <input type=checkbox name="hobby"value="旅游">旅游<br>
19 个人说明:<textArea name="information" rows=6></textArea><br>
20 <input type=submit value=" 提 交 ">
21 <input type=reset value=" 重 置 ">
22 <form>
23 </font>
24 </body>
25 </html>
yang.html也可以命名为yang.jsp,但会出现乱码必须在第一行加上jsp指令标记(page指令的contentType属性)。前者为浏览器的形式打开!
1 receive.jsp
2 <%@ page contentType="text/html;Charset=gbk" %>
3 <html>
4 <title>第二题2</title>
5 <body bgcolor=cyan>
6 <font size=20 color=red>
7 <% String name=request.getParameter("name");
8 String password=request.getParameter(" password");
9 String sex=request.getParameter("sex");
10 String Class=request.getParameter("Class");//class是关键字首字母C必须大写
11 String hobby[]=request.getParameterValues("hobby");
12 String information=request.getParameter("information");
13
14 out.print("姓名:"+name+"<br>");
15 out.print("密码:"+password+"<br>");
16 out.print("性别:"+sex+"<br>");
17 out.print("班级:"+Class+"<br>");
18 out.print("爱好:");
19 for(int i=0;i<hobby.length;i++)
20 out.print(hobby[i]+""+" ");
21 out.print("<br>个人说明:"+information);
22 %>
23 </font>
24 </body>
25 </html>