servlet登录(判断是否第一次登录及上一次登录时间)案例

本文通过一个实例介绍了如何使用Servlet实现登录功能,并在登录时判断用户是否为首次登录以及展示上一次登录的时间。涉及的文件包括myLogin.jsp登录页面、afterLogin.jsp登录成功后的提示页面、myLoginServlet.java处理登录请求的Servlet以及myLoginFilter.java过滤器,用于增强登录安全性。
摘要由CSDN通过智能技术生成

myLogin.jsp 登录页面


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

<form action="/myLoginServlet" method="post">
    <div style="width:300px;height:400px;background: rgba(203, 249, 241, 0.566);">

        <div style="width:150px;height:100px;color: rgba(31, 38, 170, 0.778);text-align: center;line-height: 100px;">
            <h2>欢迎登录</h2>
        </div>

        <div style="width:200px;height:200px;margin:auto;text-align: center;">
            <div style="height:97px;" display:inline-block>
                <input type="text" name="userName" id="userName" placeholder="用户名">
            </div>

            <div style="height:97px;">
                <input type="password" name="pwd" id="pwd" placeholder="密码">
            </div>

        </div>

        <div style="width:300px;height: 100px;text-align: center;margin:auto;line-height:100px;">

            <button type="submit" style="margin:auto">登录</button>

            <div style="height:50px;line-height: 50px;color: red">
                <h6>${requestScope.message}</h6>
            </div>

        </div>


    </div>
</form>


</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值