---
title: "session 超时处理"
author: "master3003"
date: "2011-09-24T09:02:45Z"
tags: []
categories: ["Web前端"]
slug: "session"
draft: false
lastmod: "2011-09-24T09:02:45Z"
id: 1179422
url: "https://master3003.iteye.com/blog/1179422"
---

在servlet中是这样写的： 

import   javax.servlet.*; 
import   javax.servlet.http.*; 
import   java.io.*; 
import   java.util.*; 

public   class   sv1   extends   HttpServlet 
{ 
        private   static   final   String   CONTENT_TYPE   =   "text/html;   charset=GBK "; 
        /**Initialize   global   variables*/ 
        public   void   init()   throws   ServletException 
        { 
        } 
        /**Process   the   HTTP   Post   request*/ 
        public   void   doPost(HttpServletRequest   request,   HttpServletResponse   response)   throws   ServletException,   IOException 
        { 
                response.setContentType(CONTENT_TYPE); 
                PrintWriter   out   =   response.getWriter(); 
                response.addHeader(   "aaa ",   "abcde "   ); 
                response.sendRedirect(   "http://localhost:7001/cu.jsp "   ); 
        } 
        /**Clean   up   resources*/ 
        public   void   destroy() 
        { 
        } 
} 
在cu.jsp中显示请求头中没有我加入的aaa。 
 
 
 
对我有用 丢个板砖 引用 举报 管理 TOP 回复次数：2  
 
headstream
 
(大宝) 

等　级： 

 #1楼 得分：0回复于：2002-04-22 15:13:52up一下 
 
 
对我有用 丢个板砖 引用 举报 管理 TOP  
 
dylanwolf
 


等　级： 

 #2楼 得分：0回复于：2002-04-22 15:35:45我觉得你调用   response.sendRedirect()后，客户端直接去连接   cu.jsp，并不会把你的   Header给加进去