Difference between Tomcat's extraResourcePaths and aliases to access an external directory--转

Question:

Simple question: In Tomcat7, what‘s the difference between using extraResourcePaths and aliases to access an directory outside the application?

I can use either of these two server.xml snippets and they both seem to work. Both seem to load this URL successfully: http://localhost/app/images/box.jpg. Is there an advantage to using one over the other?

<Context docBase="Eclipse_Project" path="/app"
        reloadable="true" source="org.eclipse.jst.j2ee.server:Eclipse_Project"
        aliases="/images=D:\path\to\images"/>

or

<Context docBase="Eclipse_Project" path="/app"
        reloadable="true" source="org.eclipse.jst.j2ee.server:Eclipse_Project">
        <Resources className="org.apache.naming.resources.VirtualDirContext"
                extraResourcePaths="/images=D:\path\to\images"/>
</Context>
Answer:

This is the result of having multiple different ways of pulling in resources that aren‘t part of a WAR or exploded directory. Frankly it is a mess long overdue a clean-up. The ‘overlay‘ (or whatever it ends up being called) feature proposed for Servlet 3.1 (i.e. Tomcat 8) has prompted a major clean-up. All the current implementations will be unified into a single implementation. It isn‘t pretty though, and it is going to take a while to complete.

Aliases are treated as external to the web application resources. The DirContext checks aliases before it checks its internal resources. Hence when you request the real path you get the original.

If you use extraResourcePaths they are treated as part of the web application resources. It looks like Eclipse has triggered a copy of application resources to the work directory. This is usually done to avoid file locking. Since the extraResourcePaths are treated as part of the webapp, they get copied too and getRealPath() reports the copied location since that is where Tomcat is serving the resources from.



原文地址:http://stackoverflow.com/questions/11138701/difference-between-tomcats-extraresourcepaths-and-aliases-to-access-an-external

Difference between Tomcat's extraResourcePaths and aliases to access an external directory--转

时间: 2024-10-05 09:35:03

Difference between Tomcat's extraResourcePaths and aliases to access an external directory--转的相关文章

Tomcat启动时卡在&ldquo;INFO: Deploying web application directory ......&rdquo;的解决方法

转载地址:http://blog.csdn.net/njchenyi/article/details/46641141 第一次遇到Tomcat在Linux服务器启动卡住的情况,情况很简单,tomcat启动以后卡在INFO: Deploying web application directory ......这句话,具体会卡多久就没测试了.google.baidu都没找到解决方法. 幸亏UCloud的技术支持人员给出了解决方案. 找到jdk1.x.x_xx/jre/lib/security/Jav

Tomcat启动时卡在“INFO: Deploying web application directory ”

今天在linux上的tomcat部署一个网站时,在刚启动tomcat的时候提示启动成功,然后也能访问成功. 可是第二次启动时虽然没有报错,但无法访问tomcat,查看了catalina.out日志,发现tomcat卡在了INFO: Deploying web application directory ...... 后来看了一篇博文解决了问题.在 $JAVA_HOME/jre/lib/security/java.security内,将securerandom.source的内容改为file:/d

Mac系统下安装Tomcat,以及终端出现No such file or directory的错误提示解决方案

Tomcat,作为一个免费的服务器口碑实在太好,本想安装一个研究研究,无奈电脑是mac系统,在网上搜了一些安装方法总是出错,直到遇到了这篇博客,http://www.cnblogs.com/qingyuan/p/4145175.html. 步骤1:找到Tomcat官网  传送门:http://tomcat.apache.org/download-90.cgi         找到下载区zip格式和tar.gz格式都行,我选的是tar.gz 2:解压后放入Library目录下(也就是资源库),将名

启动tomcat时,一直卡在Deploying web application directory这块的解决方案

本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项目一直都访问不了,看了一下日志: [email protected] bin]# tail -f ../logs/catalina.out 09-Jun-2017 15:57:06.666 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 09-

linux环境安装tomcat8,启动时,报not touch:/user/tomcat/tomcat8/logs/catalina.out:not a file or directory

问题原因:我的jdk和tomcat都放在root目录下新建的user目录中,但是在配置JAVA_HOME时,路径没有配对.配置如下: export JAVA_HOME=/user/jdk/jdk1.7.0_80 export JRE_HOME=/user/jdk/jdk1.7.0_80/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export PATH=$PATH:$JAV

http://wiki.apache.org/tomcat/HowTo

http://wiki.apache.org/tomcat/HowTo Contents Meta How do I add a question to this page? How do I contribute to Tomcat's documentation? Installation How do I set up and run Tomcat on Macintosh OS X? How do I set up and run Tomcat on Solaris 10? How do

Tomcat的安装和使用

Tomcat的安装和使用 =============================================================================== 概述: =============================================================================== Tomcat的安装及程序环境  1.安装Tomcat ★Tomcat binary release: # tar xf apache-tomcat

tomcat自动部署脚本

#!/bin/bash #defined now=`date +%Y%m%d%H%M%S` TOMCAT_HOME="/usr/tomcat7/apache-tomcat-7.0.70/" TOMCAT_PORT=8080 PROJECT="$1" BACKUP_DIR="/tomcat_back/$PROJECT/$now" #param validate; if [ $# -lt 1 ]; then echo "you must u

tomcat 安装

来自:http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos Install Tomcat 7 on CentOS, RHEL, or Fedora This post will cover installing and basic configuration of Tomcat 7 on CentOS 5.x. or CentOS 6.x Tomcat 7 implements the JavaServer Pages 2