代码改变世界

第一个JSP登录跳转

2018-04-23 16:27  HHFFZ  阅读(797)  评论(0编辑  收藏  举报
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>电子登录系统</title>
</head>
<body>
<center>

<form action="examplejbdemo.jsp"   method="post">
用户名:
<input type="text" name="username">
<br/><br/>&nbsp;&nbsp;码:
<input type="text" name="password">
<br/><br/>
学  号:
<input type="text" name="xuehao">
<br/>
<br/>        选填:<br>
邮 箱:<input type="text" name="youxiang">
<br/><br/>

生 日:
<input type="text" name="brithday">
<br/><br/>
身 高:
<input type="text" name="higt">
<br/><br/>
<input type="submit" value="提交"/>
</form>
</center>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="javabean.User" %>
<!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=UTF-8">
<title>用户信息</title>
</head>
<body>
<jsp:useBean id="userbean" scope= "page" class="javabean.User"/>
<jsp:setProperty property="*" name="userbean"  />

<%
    if("123".equals(userbean.getPassword()))
    {
        
         RequestDispatcher rd = request.getRequestDispatcher("NewFile.jsp"); 
         rd.forward(request,response); 
        
    }
    
%>
密码不是123,,没有跳转;
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
跳转成功;
</body>
</html>