register.html
register_check.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>用户注册</title>
</head>
<body>
<center>
<form action="register_check.jsp" method="post">
用户名:<input type ="text" name="name"><br>
密码:<input type ="password" name="password"><br>
性别:<input type="radio" name="sex" value="男">男
<input type="radio" name="sex" value="女">女
<br>
爱好:<input type="checkbox" name="like" value="体育">体育
<input type="checkbox" name="like" value="音乐">音乐
<input type="checkbox" name="like" value="美术">美术
<br>
国家:<select name="country">
<option value="中国" selected>中国</option>
<option value="美国" selected>美国</option>
<option value="英国" selected>英国</option>
</select>
<br>
备注:<textarea name="beizhu" cols="20" rows="3"></textarea>
<br>
<input type="submit" value="提交"><input type="reset" value="重填">
</form>
</center>
</body>
</html>
register_check.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>注册处理页面</title>
</head>
<body>
<h1>使用脚本段代码处理注册信息</h1>
<%
request.setCharacterEncoding("GBK");
String name= request.getParameter("name");
String password = request.getParameter("password");
String sex=request.getParameter("sex");
String[] likes=request.getParameterValues("like");
String country = request.getParameter("country");
String beizhu=request.getParameter("beizhu");
%>
<h1>打印出注册信息<br>
姓名:<%=name %><br>
密码:<%=password %><br>
性别:<%=sex %><br>
爱好:<%for(int i=0;i<likes.length;i++){
String like=likes[i];
%>
<%=like %>
<% } %><br>
国家:<%=country %><br>
备注:<%=beizhu %><br>
</h1>
</body>
</html>