yang哥

博客园 首页 新随笔 联系 订阅 管理
 1 <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
 2 <!doctype html>
 3 <html>
 4     <head>
 5         <title>login</title>
 6         <meta http-equiv="content-type" comtent="text/html;charset=utf-8"/>
 7     </head>
 8     <body>
 9         <h1><font color="red">欢迎</font></h1>
10         <form action="loginCheck.jsp" method="get">
11             <table>
12                 <tr>
13                     <td>用户名:</td>
14                     <td><input type="text" name="name" value=
15                     "<%=request.getParameter("name")%>" /></td>
16                 </tr>
17                 <tr>
18                     <td>密码:</td>
19                     <td><input type="password" name="password"/></td>
20                 </tr>
21                 <tr>
22                     <td><input type="submit" value="登录"/></td>
23                 </tr>
24             </table>
25         </form>
26     </body>
27 </html>
View Code
<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!doctype html>
<html>
    <head>
    <title>loginCheck</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    </head>
    <body>
        <%
            String name = request.getParameter("name");
            String pass = request.getParameter("password");
        %>
        <%
            //if(name.equals("QQ") && password.equals("123"))
            if("QQ".equals(name) && "123".equals(pass))
        {
        %>
        <%--forward作用是转发客户端的请求 --%>
                <jsp:forward page="success.jsp">
                <jsp:param name="user" value="<%=name %>"/>
                </jsp:forward>
        <% }
            else 
            %>
            <%{
            %>    <jsp:forward page="login.jsp">
                <jsp:param name="name" value="<%=name %>"/>
                </jsp:forward>
            <%}
            %>
            
    </body>
</html>
 1 <%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
 2 <!doctype>
 3 <html>
 4     <head>
 5         <title>success</title>
 6         <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
 7     </head>
 8     <body>
 9         <h2>登录成功</h2>
10         <hr/>
11         欢迎<%=request.getParameter("user")%>
12     </body>
13 </html>

posted on 2014-12-25 23:53  woniuyang  阅读(1861)  评论(0编辑  收藏  举报