getInfo,jsp
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>" target="_blank" rel="external nofollow" >
<title>My JSP 'getInfo.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css" target="_blank" rel="external nofollow" >
-->
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
String username=request.getParameter("username");
String password=request.getParameter("password");
String sex=request.getParameter("sex");
String country=request.getParameter("country");
String lan[]=request.getParameterValues("language");
String favorite[]=request.getParameterValues("favorite");
out.print("使用者名:"+username+"<br>");
out.print("密碼:"+password+"<br>");
out.print("性别:"+sex+"<br>");
out.print("國籍:"+country+"<br>");
%>
語言:
<%for(int i=0;i<lan.length;i++){
out.print(lan[i]+" ");
}
%>
<br>
愛好:
<%
if(favorite==null)
{
out.print("累感不愛");
}
else
{
for(int i=0;i<favorite.length;i++){
out.print(favorite[i]+" ");
}
}
%>
<table align="center" border=1>
<tr><td width=150>項目</td><td width=450>資訊</td></tr>
<tr><td>姓名</td><td><%=username %></td></tr>
<tr><td>密碼</td><td><%=password %></td></tr>
<tr><td>性别</td><td><%=sex %></td></tr>
<tr><td>國籍</td><td><%=country %></td></tr>
<tr><td rowspan=<%=lan.length%>> 語言</td>
<td> <%=lan[0]%></td> </tr>
<%for(int i=1;i<lan.length;i++){%>
<tr><td> <%=lan[i]%></td></tr>
<%
} %>
<%
if(favorite==null)
{%>
<tr><td rowspan=1>愛好</td>
<td> 無</td> </tr>
<%
}
else
{%>
<tr><td rowspan=<%=favorite.length%>>愛好</td>
<td> <%=favorite[0]%></td> </tr>
<%
for(int i=1;i<favorite.length;i++){
%>
<tr><td> <%=favorite[i]%></td></tr>
<%
}
}%>
</table>
<br>
</body>
</html>
myInfo.html
<!DOCTYPE html>
<html>
<head>
<title>myInfo.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css" target="_blank" rel="external nofollow" >-->
<style type="text/css">
body
{
font-size:12px;
}
.center
{
margin:0 auto;
width:600px;
background:lightblue;
padding:10px 50px ;
}
.title
{
font-size:20px;
color:blue;
font-weight:bold;
text-align:center;
}
</style>
</head>
<body>
<div class="center">
<form method="post" action="getInfo.jsp">
<p class="title">個人資訊</p>
<p>使用者名:<input type="text" name="username"></p>
<p>密 碼:<input type="password" name="password"></p>
<p>性别:<input type="radio" name="sex" value="男" checked>男
<input type="radio" name="sex" value="女">女</p>
<p>國籍:<select name="country" style="width:100px;">
<option value="中國" selected>中國</option>
<option value="台灣">台灣</option>
<option value="日本">日本</option>
<option value="美國">美國</option>
<option value="其他">其他</option>
</select></p>
<p>語言:<br><select name="language" size=5 multiple style="width:100px;">
<option value="漢語" selected>漢語</option>
<option value="英語" selected>英語</option>
<option value="法語">法語</option>
<option value="西班牙語">西班牙語</option>
<option value="其他">其他</option>
</select></p>
<p> 愛好:<br>
<input type="checkbox" name=favorite value="電腦">電腦
<input type="checkbox" name=favorite value="學習">學習
<input type="checkbox" name=favorite value="體育">體育
<input type="checkbox" name=favorite value="其他">其他 </p>
<p>個人簡介:<br>
<textarea name="text" rows=6 cols=80>
</textarea></p>
<p align="center"><input type="submit" value="注冊"></p>
</form>
</div>
</body>
</html>