⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loginservlet.java

📁 NEWS publish. JSP编写.系统测试用户名随便,直接点确定进入后数据库用户名/密码:随便
💻 JAVA
字号:
package com.ideas.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import com.ideas.util.Configuration;
import com.ideas.bean.userBean;
import java.util.*;

public class LoginServlet
    extends HttpServlet {

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws
      IOException, ServletException {
    String name = req.getParameter("sUserName");
    String password = req.getParameter("sPassword");
	
    userBean myBean = new userBean();
    myBean.getMyConnPool();
    String id = myBean.login(name,password);

    String go = "";
    if (!id.equals("-1")) {
      HttpSession session = req.getSession(true);
      session.setAttribute("login", "true");
      session.setAttribute("user",name);



     go = "index.jsp";
    }
    else {
      go = "login.jsp";
    }

    myBean.releaseMyConnPool();
    res.sendRedirect(go);

  }

  public void doPost(HttpServletRequest req, HttpServletResponse res) throws
      IOException, ServletException {
    doGet(req, res);

  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -