package com.xfaccp;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class MyServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
CheckLogin c =new CheckLogin();
if(c.isLogin(request))
{
//将用户的名字放入session中
HttpSession session =request.getSession();
String name=request.getParameter("txtName");
session.setAttribute("userName",name);
//取得登陆框中复选框,保存用户的姓名到cookie中
if(request.getParameter("checkbox")!=null)
{
//生成一个cookie
Cookie coo=new LongTimeCookie("loginName",name);
response.addCookie(coo);
}
response.sendRedirect("loginAccess.jsp");
}
else
response.sendRedirect("loginFail.jsp");
}
}
实现自动登陆(java) 实现自动登陆(java)
3星 · 超过75%的资源 需积分: 1 19 浏览量
2009-10-19
18:20:52
上传
评论 3
收藏 10KB RAR 举报
qianjunxian
- 粉丝: 22
- 资源: 34
最新资源
- Screenshot_20240509_034911_com.tencent.mtt.jpg
- 基于python实现的医学影像体脂分割+源代码+文档说明(课程设计)
- 基于python实现的医学影像(MIR, CT )图像分割源码+文档说明(高分课程设计)
- 基于python+JavaScript实现的医学影像分割+源代码+文档说明+截图演示+数据(高分毕业设计)
- 基于U-net+pytorch实现的医学影像分割python源码+文档说明+数据+界面截图+博客介绍
- 课程设计-基于Pytorch实现MNIST数据集的手写数字识别源码+数据(Gui界面)+文档说明+模型
- 软件开发国家标准.xls
- pytorch-CNN-SBATM-ubuntudemo
- matplotlibdemo
- pytorch-CNN-dht11温湿度传感器笔记
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈