html+jsp(表單示例)
1:html
<!DOCTYPE html>
<html><head>
<title>表單例項</title>
<meta name="keywords" content="keyword1,keyword2,keyword3">
<meta name="description" content="this is my page">
<meta name="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<h3 align="center">使用者註冊</h3>
<form name="myForm" action="receive.jsp" method="post">
<table border="1" align="center">
<tr>
<td>使用者ID:</td>
<td><input type="text" name="userid"></td>
</tr>
<tr>
<td>密碼:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>確認密碼:</td>
<td><input type="password" name="password1"></td>
</tr>
<tr>
<td>使用者名稱:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>真實姓名:</td>
<td><input type="text" name="userrealname"></td>
</tr>
<tr>
<td>性別:</td>
<td><input type="radio" name="usersex" value="男">男
<input type="radio" name="usersex" value="女">女</td>
</tr>
<tr>
<td>職業:</td>
<td><input type="text" name="userjob"></td>
</tr>
<tr>
<td>出生日期:</td>
<td>
<select name="birthyear" size="1">
<option value="2001" selected>1991</option>
<option value="2000" >2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1991">1990</option>
</select>年
<select name="birthmonth" size="1">
<option value="1" selected>1</option>
<option value="2" >2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>月
</td>
</tr>
<tr>
<td>證件型別</td>
<td>
<select name="UserID" >
<option value="身份證" checked>身份證</option>
<option value="學生證">學生證</option>
<option value="教師證">教師證</option>
</select>
</td>
<tr>
<td colspan="2" align="center">
<input type="submit" value="提交">
<input type="reset" value="取消">
</tr>
</tr>
</table>
</form>
</body>
</html>
2:jsp<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>接收表單</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">
</head>
<body>
<%
request.setCharacterEncoding("UTF-8");
int id=Integer.parseInt(request.getParameter("userid"));
String password=request.getParameter("password");
String name=request.getParameter("username");
String realname=request.getParameter("userrealname");
String sex=request.getParameter("usersex");
String job=request.getParameter("userjob");
int year= Integer.parseInt(request.getParameter("birthyear"));
int month=Integer.parseInt(request.getParameter("birthmonth"));
String UserID=request.getParameter("UserID");
%>
<h2>歡迎訪問本頁面</h2>
<ol type="1">
<li>使用者ID:<%=id%></li>
<li>密碼:<%=password%></li>
<li>使用者名稱:<%=name%></li>
<li>真實名字:<%=realname%></li>
<li>性別:<%=sex%></li>
<li>職業:<%=job%></li>
<li>出生年月:<%=year%>年<%=month%>月</li>
<li>證件型別:<%=UserID%></li>
</ol>
</body>
</html>