• 每日日报2020 12/12


    今天双十二,是个事变的好日子。

    package libraryservlet;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import dao.SchoolDaoImpl;
    import entity.School;

    /**
    * Servlet implementation class libraryservlet
    */
    @WebServlet("/libraryservlet")
    public class libraryservlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public libraryservlet() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    //response.getWriter().append("Served at: ").append(request.getContextPath());
    request.setCharacterEncoding("utf-8");
    response.setContentType("text/html;charset=utf-8");

    String ID=request.getParameter("username");
    HttpSession session=request.getSession();
    session.setAttribute("ID", ID);//存储数据
    request.setAttribute("ID", ID);
    String password=request.getParameter("password");
    String method=request.getParameter("profession");
    SchoolDaoImpl sd=new SchoolDaoImpl();
    if("1".equals(method)) {
    try{
    System.out.println(1);

    if("123456".equals(ID)&&"654321".equals(password)) {
    response.getWriter().println("<script type='text/javascript'> alert('登录成功')</script>");
    request.getRequestDispatcher("manage.jsp").forward(request, response);}
    else {
    response.getWriter().println("<script type='text/javascript'> alert('密码或账号错误')</script>");
    request.getRequestDispatcher("library.jsp").forward(request, response);}
    }catch(Exception e){
    System.out.println("失败");
    e.printStackTrace();
    }
    }

    if("2".equals(method)) {
    try{
    System.out.println(1);

    String stupass=sd.showstuname(ID);


    if(password.equals(stupass)) {
    SchoolDaoImpl sd1=new SchoolDaoImpl();
    java.util.List<School> list=sd1.stushow(ID);

    request.setAttribute("list", list);
    response.getWriter().println("<script type='text/javascript'> alert('登录成功')</script>");
    request.getRequestDispatcher("student.jsp").forward(request, response);}
    else {
    response.getWriter().println("<script type='text/javascript'> alert('账号或密码错误')</script>");
    request.getRequestDispatcher("library.jsp").forward(request, response);}

    }catch(Exception e){
    System.out.println("失败");
    e.printStackTrace();
    }
    }


    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

  • 相关阅读:
    redis实现高并发下的抢购/秒杀功能
    redis分布式锁的实现(setNx命令和Lua脚本)
    【JAVA代码审计】——1、Spring框架知识篇
    使用edjpgcom工具制作一句话图片木马
    史上最强内网渗透知识点总结
    2018年云上挖矿分析报告
    Solidity 安全:已知攻击方法和常见防御模式综合列表
    【PHP渗透技巧拓展】————3、LFI、RFI、PHP封装协议安全问题学习
    【PHP渗透技巧拓展】————2、利用 Gopher 协议拓展攻击面
    【RPO技巧拓展】————5、RPO攻击初探
  • 原文地址:https://www.cnblogs.com/song-1/p/14177213.html
Copyright © 2020-2023  润新知