tomcat-连接器

1 org.apache.catalina.util.StringManager

        tomcat将错误信息存储在properties文件中,这些properties文件分别位于不同的包中,包含该包中任何类可能抛出的所有异常信息。每个properties文件由stringManager的一个实例处理。错误信息的文件名为LocalStrings_language.properties。通过指定包名,获取stringManager。

org.apache.catalina.tribes.util.StringManager

private static final Map<String, Map<Locale,StringManager>> managers =
            new Hashtable<>();


public static final StringManager getManager(String packageName) {
        return getManager(packageName, Locale.getDefault());
    }

public static final synchronized StringManager getManager(
            String packageName, Locale locale) {

        Map<Locale,StringManager> map = managers.get(packageName);
        if (map == null) {
            /*
             * Don't want the HashMap to be expanded beyond LOCALE_CACHE_SIZE.
             * Expansion occurs when size() exceeds capacity. Therefore keep
             * size at or below capacity.
             * removeEldestEntry() executes after insertion therefore the test
             * for removal needs to use one less than the maximum desired size
             *
             */
            map = new LinkedHashMap<Locale,StringManager>(LOCALE_CACHE_SIZE, 1, true) {
                private static final long serialVersionUID = 1L;
                @Override
                protected boolean removeEldestEntry(
                        Map.Entry<Locale,StringManager> eldest) {
                    if (size() > (LOCALE_CACHE_SIZE - 1)) {
                        return true;
                    }
                    return false;
                }
            };
            managers.put(packageName, map);
        }

        StringManager mgr = map.get(locale);
        if (mgr == null) {
            mgr = new StringManager(packageName, locale);
            map.put(locale, mgr);
        }
        return mgr;
    }

        想获取错误信息,可以使用getString(String key)方法


    private final ResourceBundle bundle;

    private StringManager(String packageName, Locale locale) {
        String bundleName = packageName + ".LocalStrings";
        ResourceBundle bnd = null;
        try {
            bnd = ResourceBundle.getBundle(bundleName, locale);
        } catch (MissingResourceException ex) {
            // Try from the current loader (that's the case for trusted apps)
            // Should only be required if using a TC5 style classloader structure
            // where common != shared != server
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if (cl != null) {
                try {
                    bnd = ResourceBundle.getBundle(bundleName, locale, cl);
                } catch (MissingResourceException ex2) {
                    // Ignore
                }
            }
        }
        bundle = bnd;
        // Get the actual locale, which may be different from the requested one
        if (bundle != null) {
            Locale bundleLocale = bundle.getLocale();
            if (bundleLocale.equals(Locale.ROOT)) {
                this.locale = Locale.ENGLISH;
            } else {
                this.locale = bundleLocale;
            }
        } else {
            this.locale = null;
        }
    }


    public String getString(String key) {
        if (key == null){
            String msg = "key may not have a null value";
            throw new IllegalArgumentException(msg);
        }

        String str = null;

        try {
            // Avoid NPE if bundle is null and treat it like an MRE
            if (bundle != null) {
                str = bundle.getString(key);
            }
        } catch (MissingResourceException mre) {
            //bad: shouldn't mask an exception the following way:
            //   str = "[cannot find message associated with key '" + key +
            //         "' due to " + mre + "]";
            //     because it hides the fact that the String was missing
            //     from the calling code.
            //good: could just throw the exception (or wrap it in another)
            //      but that would probably cause much havoc on existing
            //      code.
            //better: consistent with container pattern to
            //      simply return null.  Calling code can then do
            //      a null check.
            str = null;
        }

        return str;
    }

org.apache.catalina.connector.Connector     Implementation of a Coyote connector

http 1.1 特性

1 长连接

显示启用长久连接, 请求头设置 connection:keep-alive

2 块编码

资源分多次返回时,需告知content-length,客户端才知如何解析。但很多时候,不知content-length,可使用transfer-encoding的特殊请求头,指明字节流将会分块发送,每一块由16进制块长度+\r\n,换行,+具体数据。0\r\n表明事务已经完成。

225456_SbsA_1380557.png

3 状态码100

客户端准备发送较长请求体,不确定服务端是否接收时,发送 Expect: 100-continue请求头,等待服务端确认。若服务端可以接受并处理该请求,发送 Http/1.1 100 Continue响应头+crlf字符,然后继续读取输入流的内容 

204858_p71T_1380557.png

requestFacde

转载于:https://my.oschina.net/u/1380557/blog/799766

### 回答1: 要下载tomcat-redis-session-manager-1.2-tomcat-7.jar,您可以按照以下步骤进行操作: 1. 打开您的网络浏览器,进入您通常使用的搜索引擎网站,如Google或百度。 2. 在搜索框中输入“tomcat-redis-session-manager-1.2-tomcat-7.jar下载”并按下回车键。 3. 检查搜索结果,找到可靠且权威的网站,比如Apache官方网站或者Maven中央库。 4. 点击打开所选网站,并在搜索栏中输入“tomcat-redis-session-manager-1.2-tomcat-7.jar”。 5. 您会看到相关的下载链接或页面,点击下载按钮或链接。 6. 选择一个合适的下载位置或文件夹,单击“保存”或“确认”按钮开始下载。 7. 等待下载完成,这可能需要一些时间,具体取决于您的网络连接速度和该文件的大小。 8. 下载完成后,在指定的下载位置或文件夹中找到下载的jar文件。 现在,您已经成功下载了tomcat-redis-session-manager-1.2-tomcat-7.jar文件,并可以将其用于相应的项目或应用程序中。请确保在使用该jar文件之前,仔细阅读相关的文档和说明,以确保正确配置和使用。 ### 回答2: 要下载tomcat-redis-session-manager-1.2-tomcat-7.jar,您可以按照以下步骤进行操作: 1. 打开您所用的网络浏览器(如Chrome、Firefox等)。 2. 在浏览器的地址栏中输入“tomcat-redis-session-manager-1.2-tomcat-7.jar”进行搜索。 3. 找到一个可信赖的下载来源,例如官方网站、GitHub等,确保文件来源可靠。 4. 点击下载链接或按钮,开始下载jar文件。 5. 下载完成后,您可以选择保存文件到您的电脑的特定目录,以便日后使用。 6. 如果您使用的是Tomcat服务器(版本7),则可以将该jar文件放置在您的Tomcat安装目录(通常是"tomcat7/lib"文件夹)下的“lib”文件夹中。 7. 确保您已经正确配置了Tomcat服务器,以便正确使用tomcat-redis-session-manager-1.2-tomcat-7.jar文件。 8. 现在,您已经成功下载并准备好使用tomcat-redis-session-manager-1.2-tomcat-7.jar文件了。 请注意,下载jar文件是一种常见的操作,确保您从可信赖的来源下载文件,以避免潜在的安全问题。另外,请根据您所使用的Tomcat服务器的版本选择正确的jar文件。 ### 回答3: 要下载 tomcat-redis-session-manager-1.2-tomcat-7.jar,您可以按照以下步骤进行操作: 1. 确定您的计算机上已安装 Java 运行时环境(JRE)和 Apache Tomcat 7。如果没有安装,您需要先下载和安装这些软件。 2. 打开您的网络浏览器,转到可信赖的软件下载网站,例如 Apache Tomcat 的官方网站或 Maven 仓库。 3. 在搜索框中输入 "tomcat-redis-session-manager-1.2-tomcat-7.jar",然后点击搜索按钮。 4. 在搜索结果中找到正确的版本,通常它会有与您正在使用的 Tomcat 版本相匹配的名称。 5. 单击下载按钮或链接,以开始下载该文件。文件大小可能会有所不同,所以可能需要一些时间来完成下载。 6. 一旦下载完成,将 jar 文件保存到您计算机上的合适位置,例如 Tomcat 的 lib 目录。 7. 确保您的 Tomcat 服务器已关闭。如果正在运行,请停止它。 8. 打开 Tomcat 的安装目录,找到和打开 conf 目录。 9. 在 conf 目录中找到 context.xml 文件,然后用文本编辑器打开。 10. 在 context.xml 文件中找到 `<Context>` 标签,并在其内部添加以下内容: ``` <Manager className="de.javakaffee.web.session.RedisSessionManager" host="localhost" port="6379" database="0" maxInactiveInterval="60" /> ``` 根据您的 Redis 服务器设置,可能需要进行其他自定义配置,例如主机名、端口号和数据库。 11. 保存并关闭 context.xml 文件。 12. 重新启动 Tomcat 服务器,以使更改生效。 现在,您已经成功下载了 tomcat-redis-session-manager-1.2-tomcat-7.jar,并将其集成到您的 Tomcat 服务器中。您可以使用 Redis 来存储和管理在 Tomcat 上运行的应用程序的会话。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值