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

📄 logincservlet.java~1~

📁 c++通信编程学习1
💻 JAVA~1~
字号:
package com.j2ee.servlet.login;
import com.j2ee.func.login.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class Logincservlet extends HttpServlet{
    public Logincservlet() {
        try {
            jbInit();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private static final String CONTENT_TYPE = "text/html; charset=GBK";

    //Initialize global variables
    public void init() throws ServletException {
    }

    //Process the HTTP Get request
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        String name= request.getParameter("name");
        String password= request.getParameter("password");
        String usertype= request.getParameter("usertype");
        if (name.trim().equals("") || password.trim().equals("")) {
            request.getRequestDispatcher("index_error.jsp?error_code=codeisnull").forward(request,response);

        } else {
                Logininfo logininfo=new Logininfo();
                logininfo.setname(name);
                logininfo.setpassword(password);
                logininfo.setusertype(usertype);

                //PrintWriter out = response.getWriter();
                Loginfunc loginfunc=new Loginfunc(logininfo);
                //out.println(loginfunc.isloginAccess());
                //out.close();
                if(loginfunc.isloginAccess()){
                    response.setContentType(CONTENT_TYPE);
                    PrintWriter out = response.getWriter();
                    out.println("<html>");
                    out.println("<head><title>loginservlet</title></head>");
                    out.println("<body bgcolor=\"#ffffff\">");
                    out.println("<p>登陆成功</p>");
                    out.println(name+request.getMethod());
                    out.println(password);
                    out.println("<a href=\"index.jsp\"> 返回</a>");
                    out.println("</body>");
                    out.println("</html>");
                    out.close();
                }
                else{
                  request.getRequestDispatcher("loginindex.jsp").forward(request,response);

                }
        }



           // if(usertype1.equals("0"){ ;}
           // else{}


    }

    //Process the HTTP Post request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
            ServletException, IOException {
        doGet(request, response);
    }

    //Clean up resources
    public void destroy() {
    }

    private void jbInit() throws Exception {
    }
}

⌨️ 快捷键说明

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