高分相赠,高手请进 ,我想要个LOGout时销毁SESSION的JSP页面和服务器端代码,谁可以给我一份谢谢了 。
解决方案 »
- GWT 实战效果 先来者有分
- oracle的java.sql.SQLException: Io 异常 The Network Adapter could not establish the connection
- 页面跳转问题
- 关于虚拟目录配置的问题
- 非常容易的一个关于获取URL的问题,急急急!
- 请教关闭数据库连接的问题
- iTextAsia.jar(亚洲语言包)有致命bug?
- 文件名的更替
- Tomcat里怎么配才能运行Servlet
- ApplicationResources.properties??
- 关于JSP中的equals的问题
- struts 2中action取页面request对象中的对象能取出来么?
request.getSession().invalidate();
response.sendRedirect("login.jsp");
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<form action="/servlet/Login" method="post">
<input type="submit" value="注销"/>
</form>
</body>
</html>==========web.xml=======
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>Login</servlet-name>
<servlet-class>Login</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/servlet/Login</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>===============servlet====================
import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Login extends HttpServlet { /**
* Constructor of the object.
*/
public Login() {
super();
} /**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy();
} public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.getSession().invalidate();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
} public void init() throws ServletException {
// Put your code here
}
}