销毁session
package servlet;
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;
@WebServlet("/ExitServlet")
public class ExitServlet extends HttpServlet {
private static final long serialversionuid = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
HttpSession session = request.getSession();
session.invalidate();
response.sendredirect("index.jsp");
}
}
相关阅读
关于HttpSession的误解实在是太多了,本来是一个很简单的问题,怎会搞的如此的复杂呢?下面说说我的理解吧: 一个session就是一系列某用
1.HttpServletRequest获取 HttpSession session = request.getSession(); 2.HttpServletRequest request = ((ServletRequestAt
Android:销毁所有的Activity退出应用程序几种方式
Android:销毁所有的Activity退出应用程序几种方式author:DRC工作室 我们都知道,Activity是存放在栈中。在默认的情况下(standard)Acti
session.setAttribute和session.getAttribute
B/S架构中,客户端与服务器连接,在服务端就会自动创建一个session对象. session.setAttribute("username",username); 是将usernam
场景:有些实体对象可以放到HttpSession对象中,保正在一个会话期间可以随时获取这个对象的属性,例如可以将登录用户的信息写入session