当前位置 : 主页 > 编程语言 > 其它开发 >

8

来源:互联网 收集:自由互联 发布时间:2022-05-30
%@ page contentType="text/html;charset=UTF-8" language="java" %htmlhead title登录/title/headbodyscript type="text/javascript" function check() { if (login.account.value==""){ alert("请输入账号!"); return; }else if(login.psw.value==""
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<script type="text/javascript">
    function check() {
        if (login.account.value==""){
            alert("请输入账号!");
            return;
        }else if(login.psw.value=="") {
            alert("请输入密码!");
            return;
        }
        login.submit();
    }
</script>
    <form action="check.jsp" method="post" name="login">
        账号:<input type="text" name="account"><br>
        密码:<input type="password" name="psw"><br>
        <input type="checkbox" value="注册会员">注册会员
        <input type="checkbox" value="不注册会员">不注册会员<br>
        <input type="button" value="登录" onclick="check()">
    </form>
<%

%>
</body>
</html><%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
</head>
<body>
<script type="text/javascript">
    function check() {
        if (login.account.value==""){
            alert("请输入账号!");
            return;
        }else if(login.psw.value=="") {
            alert("请输入密码!");
            return;
        }
        login.submit();
    }
</script>
    <form action="check.jsp" method="post" name="login">
        账号:<input type="text" name="account"><br>
        密码:<input type="password" name="psw"><br>
        <input type="checkbox" value="注册会员">注册会员
        <input type="checkbox" value="不注册会员">不注册会员<br>
        <input type="button" value="登录" onclick="check()">
    </form>
<%

%>
</body>
</html>

  

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>check</title>
</head>
<body>

        <%
            String account=request.getParameter("account");
            String psw=request.getParameter("psw");
            if (psw.equals(account)){
                session.setAttribute("account",account);
                request.getRequestDispatcher("logSuccess.jsp").forward(request,response);
            }else {
                request.getRequestDispatcher("logFail.jsp").forward(request,response);
            }
        %>

</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登陆成功</title>
</head>
<body>
<script type="text/javascript">
    function inCart() {
        alert("加入购物车成功!")
        <%
        String[] toyName=request.getParameterValues("toys");
        session.setAttribute("toyName",toyName);
        %>
        select.submit();
    }
</script>
<%
    String account =(String) session.getAttribute("account");
    if (account == null) {
        out.print("请登录!3秒后跳转");
        response.setHeader("refresh", "3;url=login.jsp");
    } else {%>
<h1>登陆成功!</h1>
<h1>欢迎!<%=session.getAttribute("account")%>
</h1>
<h2>已成为会员!</h2><br>
<form action="user.jsp" method="post">
    <input type="hidden" name="account" value="<%=account%>">
    <input type="submit" value="查看我都购物车"><br>
</form>

<h2>商品名:</h2>
<form action="logSuccess.jsp" method="post" name="select">
迪迦(tiga):¥999<input type="checkbox" name="toys" value="tiga"><br>
赛文(Severn):¥998<input type="checkbox" name="toys" value="Severn"><br>
小怪兽(littleMonster):¥1<input type="checkbox" name="toys" value="littleMonster"><br>
<input type="button" value="加入购物车" onclick="inCart()">
</form>
<a href="logOut.jsp">退出登录</a>
<% }%>


</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登陆失败</title>
</head>
<body>
<h1>登陆失败!</h1>
</body>
</html>
<%
    String account=request.getParameter("account");
%>
<h1>欢迎!</h1>
<h2>
    您的账号:<%=account%><br>
    购物车:<br>
    <%
        request.setCharacterEncoding("utf-8");
        String[] toy=(String[]) session.getAttribute("toyName");
        if (toy==null){
            out.print("购物车空空如也!");
        }else {
            out.println(Arrays.toString(toy));
        }

    %>
</h2>
</body>
</html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>退出登录</title>
</head>
<body>
<h1>退出成功!3秒后回到主页!</h1>
<%

    session.invalidate();
    response.setHeader("refresh", "3;url=login.jsp");

%>
</body>
</html>

 

 

 

 

 

 

 

 

上一篇:ElasticSearch聚合应该怎么学
下一篇:没有了
网友评论