34、Session的维护机制

34、Session的维护机制_第1张图片
34、Session的维护机制_第2张图片
34、Session的维护机制_第3张图片
拷贝web02,为web03
右键web03 properties,web修改
34、Session的维护机制_第4张图片
新建Servlet
SessionServlet.java

package com.atguigu.login.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class SessionServlet
 */
public class SessionServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//
		System.out.println("当前请求的request对象:" + request);
		
		//获取session对象
		
		HttpSession session = request.getSession();
		
		System.out.println("当前请求的session对象:" + session);
		System.out.println("sessionID:" + session.getId());
		
		response.getWriter().println("success") ;
		
		
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}

重新运行SessionServlet.java
34、Session的维护机制_第5张图片

你可能感兴趣的:(Java-Web)