http无状态条件下的登录

http无状态条件下的登录_第1张图片http无状态条件下的登录_第2张图片

http无状态条件下的登录_第3张图片

http无状态条件下的登录_第4张图片

具体实现代码:

http无状态条件下的登录_第5张图片

前端代码:

Insert title here



后台代码:

loginservlet:

package denglu.normal;

 

import java.io.IOException;

import java.io.PrintWriter;

 

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

@WebServlet("/login")

public class loginservlet extends HttpServlet{

 

    /**

     *

     */

    private static final long serialVersionUID = 1L;

    @Override

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // TODO Auto-generated method stub

        req.setCharacterEncoding("UTF-8");

        String name=req.getParameter("username");

        String password=req.getParameter("userpad");

        resp.setContentType("text/html;charset=UTF-8");

        PrintWriter out=resp.getWriter();

        System.out.println(name);

        System.out.println(password);

        if("洲洲".equals(name)&&"123456".equals(password))

        {

        out.print("欢迎:'"+ name +"'使用
");

        out.print("您有邮件");

        }

    }

}

 

 

 

 

 

 

 

chaxunservlet:

package denglu.normal;

 

import java.io.IOException;

import java.io.PrintWriter;

 

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

@WebServlet("/chaxun")

public class chaxunservlet extends HttpServlet{

 

    /**

     *

     */

    private static final long serialVersionUID = 1L;

    @Override

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // TODO Auto-generated method stub

        String name=req.getParameter("username");

        resp.setContentType("text/html;charset=UTF-8");

        PrintWriter out=resp.getWriter();

        out.print("欢迎:'"+ name +"'使用
");

        out.print("第一封邮件
");

        out.print("第二封邮件
");

        out.print("第三封邮件
");

    }

}

 

contenservlet:

package denglu.normal;

 

import java.io.IOException;

import java.io.PrintWriter;

 

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

@WebServlet("/content")

public class contentservlet extends HttpServlet{

 

    /**

     *

     */

    private static final long serialVersionUID = 1L;

    @Override

    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // TODO Auto-generated method stub

        String name=req.getParameter("username");

        resp.setContentType("text/html;charset=UTF-8");

        PrintWriter out=resp.getWriter();

        out.print("欢迎:'"+ name +"'使用
");

        out.print("所谓的焦虑就是书读得太少,而想得又太多了");

    }

}

http无状态条件下的登录_第6张图片

http无状态条件下的登录_第7张图片

http无状态条件下的登录_第8张图片

你可能感兴趣的:(http无状态条件下的登录)