zoukankan      html  css  js  c++  java
  • JSP第四次作业(2)

    HTML代码:

    <head>
       <title>登录验证</title>
      </head>
     <body>
        <form action="index.jsp" method="post" >
            <table align="center">
            <tr>
                <td><img src="Snap1.jpg"><div style="position:absolute; left: 650px; top: 216px;  356px;">
                    <table align="right">
                        <tr>
                            <td align="right">用户名:&nbsp;</td>
                            <td height="27"><input type="text" name="u_name" size="20"/><br></td>        
                        </tr>
                        <tr>
                            <td align="right">密码:&nbsp;</td>
                            <td height="27"><input type="password" name="u_pswd" size="20"/><br></td>        
                        </tr>
                        
                        <tr>
                            <td>
                                <div style="position:absolute; left: 200px; top: 80px;  356px;">
                                    <input type="image" src="login.gif" width="101" height="22" border="0" name="submit" value="提交" />
                                </div>
                            </td>        
                        </tr>
                        
                    </table>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </body>

    JSP判断代码:

      <body>
            <%
                request.setCharacterEncoding("utf-8");
                String user=request.getParameter("u_name");
                String pwd=request.getParameter("u_pswd");
             %>
             <%
                 if(user.equals("lucky") && pwd.equals("123456")){
            out.print("你好,"+user+"!");
            //登陆成功
            request.getRequestDispatcher("MyJsp.jsp").forward(request, response);
        }else{
            //重新登录    
            response.sendRedirect("loginJsp.jsp");
            
            }
        %>
    
      </body>

    页面代码:

    <body>
            你好,Lucky!<br>
      </body>

    截图:

     

     

     

  • 相关阅读:
    GUI基础学习
    常用类string的用法
    类。对象和包--补上周
    类.对象和包
    调用函数的注意事项
    函数的简单运用
    一维数组基础
    java中scanner类的用法
    数据库——DQL(语句查询)
    数据库——JDBC
  • 原文地址:https://www.cnblogs.com/XiaoPoHai-11/p/12606932.html
Copyright © 2011-2022 走看看