JSP 页面提交例子

本文介绍了一个简单的页面注册提交小例子,包括两个页面:Login.jsp 和 Login_Success.jsp。Login.jsp 页面用于输入学员编号、姓名、登录密码和重复密码等信息,并进行基本验证。Login_Success.jsp 页面则接收来自 Login.jsp 的提交数据,显示注册成功并展示输入的学员信息。
摘要由CSDN通过智能技术生成

简单的一个页面注册提交小例子,分为两个页面

Login.jsp

以及Login_Success.jsp

 

LOGIN.JSP

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <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">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
	function formSubmit()
	  {
	  	var theForm;
		theForm = document.stuForm;
		if(theForm.stuNo.value==""){
			alert("请输入学员编号!");
			theForm.stuNo.focus();
			return false;
		}
		if(theForm.stuName.value==""){
			alert("请输入学员姓名!");
			theForm.stuName.focus();
			return false;
		}
		if(theForm.stuPass.value==""){
			alert("请输入密码!");
			theForm.stuPass.focus();
			return false;
		}
		if(theForm.stuRpass.value==""){
			alert("请输入确认密码!");
			theForm.stuRpass.focus();
			return false;
		}
		if(theForm.stuPass.value != theForm.stuRpass.value){
			alert("两次密码输入不一致!");
			theForm.stuPass.focus();
			return false;
		}

		theForm.submit();
	  }
	</script>

  </head>

  
  <body>
    <center>
    	<h1>学员注册页面</h1>
    	<form name="stuForm" action="Login_Success.jsp" method="post">
    		<table>
    			<tr>
    				<td><b>学员编号:</b></td>
    				<td><input type="text" name="stuNo"></td>
    			</tr>
    			<tr>
    				<td><b>姓名:</b></td>
    				<td><input type="text" name="stuName"></td>
    			</tr>
    			<tr>
    				<td><b>登录密码:</b></td>
    				<td><input type="password" name="stuPass"></td>
    			</tr>
    			<tr>
    				<td><b>重复密码:</b></td>
    				<td><input type="password" name="stuRpass"></td>
    			</tr>
    			<tr>
    				<td><b>性别:</b></td>
    				<td><input type="radio" value="男" name="sex" checked> 男
    				<input type="radio" value="女" name="sex" > 女
    				</td>
    			</tr>
    			<tr>
    				<td><b>出生日期:</b></td>
    				<td>
    					<select name="birthDate">
    						<option value="1988" checked>1988</option>
    						<option value="1989">1989</option>
    						<option value="1990">1990</option>
    						<option value="1991">1991</option>
    					</select>    				
    				</td>
    			</tr>
    		</table>
    		<input type="button" value="提交" name="submit1" οnclick="formSubmit()"> 	
    	</form>
    </center>
  </body>
</html>

 

 

Login_Success.jsp

<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.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">
	-->

  </head>
  
  <body>
   <!--对提交到该JSP页面含有中文的信息实现以中文正常显示-->
    <%request.setCharacterEncoding("GBK");%>
    <center>
    	<h1>注册成功</h1>
    	<table>
    		<tr>
    			<td>学员编号:</td>
    			<td><%=request.getParameter("stuNo")%></td>
    		</tr>
    		<tr>
    			<td>学员姓名:</td>
    			<td><%=request.getParameter("stuName")%></td>
    		</tr>
    		<tr>
    			<td>性别:</td>
    			<td><%=request.getParameter("sex")%></td>
    		</tr>
    		<tr>
    			<td>出生日期:</td>
    			<td><%=request.getParameter("birthDate")%></td>
    		</tr>
    		
    	</table>  
    </center>
  </body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值