zoukankan      html  css  js  c++  java
  • tomcat修改jsessionid在cookie中的名称

    1、tomcat5修改方法

    在启动项中增加org.apache.catalina.SESSION_COOKIE_NAME参数

    linux
    JAVA_OPTS=’-Dorg.apache.catalina.SESSION_COOKIE_NAME=yousessionname

    win
    set JAVA_OPTS=”-Dorg.apache.catalina.SESSION_COOKIE_NAME=yousessionname

    2、tomcat6和tomcat7修改方法相同

    在Context容器标签上增加sessionCookieName参数

    <Context path=”/” docBase=”webapp” reloadable=”false” sessionCookieName=”yoursessionname”></Context>

    3、为啥这样就好用呢?

    tomcat5时增加参数对所有Context生效,影响甚大,所以到以后的版本就仅针对Context设置了

    tomcat5源码如下
    public final class Globals
    /**
    * The name of the cookie used to pass the session identifier back
    * and forth with the client.
    */
    public static final String SESSION_COOKIE_NAME =
    System.getProperty(“org.apache.catalina.SESSION_COOKIE_NAME”,
    “JSESSIONID”);

    tomcat6和tomcat7的源码差不多,如下
    public class StandardContext
    ….省略若干
    /**
    * The name to use for session cookies. <code>null</code> indicates that
    * the name is controlled by the application.
    */
    private String sessionCookieName;
    /**
    * Gets the name to use for session cookies.
    *
    * @return  The value of the default session cookie name or null if not
    *          specified
    */
    public String getSessionCookieName() {
    return sessionCookieName;
    }

    /**
    * Sets the name to use for session cookies. Overrides any setting that
    * may be specified by the application.
    *
    * @param sessionCookieName   The name to use
    */
    public void setSessionCookieName(String sessionCookieName) {
    String oldSessionCookieName = this.sessionCookieName;
    this.sessionCookieName = sessionCookieName;
    support.firePropertyChange(“sessionCookieName”,
    oldSessionCookieName, sessionCookieName);
    }

  • 相关阅读:
    lua 取table长度
    [转] 理解 LSTM 网络
    [转]An Intuitive Explanation of Convolutional Neural Networks
    [转]How rival bots battled their way to poker supremacy
    【转】Principles of training multi-layer neural network using backpropagation
    [转]霍夫丁不等式与真实的机器学习
    [转]PLA算法总结及其证明
    jinja2 宏的简单使用总结(macro)
    Python 装饰器
    PYTHON REQUESTS的安装与简单运用
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2805353.html
Copyright © 2011-2022 走看看