首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

tomcat对sessionId的处置分析

2012-09-03 
tomcat对sessionId的处理分析tomcat 7对sessionId的处理:首先解析request请求中的sessionID:从AjpProcesso

tomcat对sessionId的处理分析

tomcat 7对sessionId的处理:

首先解析request请求中的sessionID:

从AjpProcessor.java的process(SocketWrapper<Socket> socket)调用CoyoteAdapter.process里面有的postParseRequest(org.apache.coyote.Request req, Request request,org.apache.coyote.Response res,

  Response response) 就有解析获取sessionid的过程

  /**     * Special method for adding a session cookie as we should be overriding     * any previous     * @param cookie     */    public void addSessionCookieInternal(final Cookie cookie) {        if (isCommitted()) {            return;        }        String name = cookie.getName();        final String headername = "Set-Cookie";        final String startsWith = name + "=";        final StringBuffer sb = generateCookieString(cookie);        boolean set = false;        MimeHeaders headers = coyoteResponse.getMimeHeaders();        int n = headers.size();        for (int i = 0; i < n; i++) {            if (headers.getName(i).toString().equals(headername)) {                if (headers.getValue(i).toString().startsWith(startsWith)) {                    headers.getValue(i).setString(sb.toString());                    set = true;                }            }        }        if (!set) {            addHeader(headername, sb.toString());        }    }

如果header已经有这个sessionId的cookie,则更新,否则设置到header中。

热点排行