您的位置:首页 > Web前端 > JavaScript

jsp的综合练习,一个简单的登陆系统

2010-07-24 13:41 579 查看
Model1模型,例如综合练习1。

一个简单的登陆页面

LoginForm.jsp文件

<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%>

<html>

  <head>

    <title>LoginForm</title>

  </head>

  <body>

  <center>

    <form action="LoginConf.jsp" method="post">

     <table>

       <tr>

        <td colspan="2">用户登陆</td>

       </tr>

       <tr>

         <td>用户名:</td>

         <td><input type="text" name="username"></td>

       </tr>

        <tr>

         <td>密 码:</td>

         <td><input type="password" name="userpassword"></td>

       </tr>

        <tr>

         <td colspan="2">

         <input type="submit" value="登陆"/>

         <input type="reset" value="重置"/>

         </td>

        </tr>

     </table>

    </form>

  </center>

  </body>

</html>

LoginConf.jsp文件

<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%>

<html>

  <head> 

    <title>LoginConf</title>

  </head>

  <body>

    <center>

    <%

      String username=request.getParameter("username");

      String userpassword=request.getParameter("userpassword");

     %>

    

     <%

        if("yang".equals(username)&&"1234".equals(userpassword))

        {

      %>

         <jsp:forward page="LoginSuccess.jsp"/>

       <%

       }

       else{

       %>

       <jsp:forward page="LoginFailure.jsp"/>

        <%

          }

       %>

       </center>

  </body>

</html>

LoginSuccess.jsp文件

<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%>

<html>

  <head>

    <title>登陆成功</title>

  </head>

 

  <body>

    <center>

    <h4>登陆成功</h4>

    </center>

  </body>

</html>

LoginFailure.jsp文件

<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312"%>

<html>

  <head>

    <title>登陆失败</title>

  </head>

 

  <body>

    <center>

    <h4>登陆失败</h4>

    </center>

  </body>

</html>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jsp import html java string input