第七周作业

control.jsp

<%@page import="com.gd.dao.stuDao"%>
<%@page import="com.gd.bean.stu"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    stu s = new stu();
    int id = Integer.parseInt(request.getParameter("sid"));
    s.setSid(id);
    String uname = request.getParameter("uname");
    s.setUname(uname);
    String upwd = request.getParameter("upwd");
    s.setUpwd(upwd);
    stuDao sd=new stuDao();
    if(sd.addstu(s)>0){
        //跳转注册成功页面 
    }else{
        //错误页面 
    }    
%>
<%    
    if(uname.equals("zs")&&upwd.equals("123")){
    //跳转成功登录页面
    request.getRequestDispatcher("welcome.jsp").forward(request, response);
    session.setAttribute("uname",uname);
    }
    else{
    //错误页面
    request.getRequestDispatcher("index.jsp").forward(request, response);
    }
%>

index.jsp

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<style>
    body{
    width:600px;
    height:500px;
    overflow: hidden;
    position: relative;
    background-repeat: no-repeat;
    background-image:url(chengshi_yejing-007.jpg);
    }
    
    form{
    width: 300px;
    height: 150px;
    padding-top: 10px;
    margin: 150px auto;                                          
    background: #00000000;                                     
    border-radius: 20px;                                        
    border: 3px solid #f8fcfc;
    opacity: 0.9;}
    table{
    width: 300px;
    height: 80px;
    padding-top: 0px;
    margin: 50px auto; 
    background: #00000000; 
    position:relative;

    }
}
</style>
  <head>
    
  </head>
  
  <body>
    <form name="form1" method="post" action="control.jsp" >
        <table>
        <tr>    
        <td>编号:</td>
                <td> <input type="text" name="sid" id="userName"  ></td>
                </tr>
            <tr>    
                <td>用户名:</td>
                <td> <input type="text" name="uname" id="userName"  ></td>
            </tr>
            <tr>    
                 <td>输入登录密码:</td>
                <td><input type="password" name="upwd" id="pwd"></td>
            </tr>
            
            <tr>    
                <td colspan="2">&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;<input type="submit" value="注册">&emsp;<input type="submit" value="登录"></td>
            </tr>

               
        </table>
    </form>
  </body>
</html>

welcome.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
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>
  </head>
  
  <body>
    欢迎登录!
  </body>
</html>

posted @ 2021-04-18 17:57  余归-  阅读(11)  评论(0编辑  收藏  举报