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--转的更多相关文章

  1. Tomcat 开发web项目报Illegal access: this web application instance has been stopped already. Could not load [org.apache.commons.pool.impl.CursorableLinkedList$Cursor]. 错误

    开发Java web项目,在tomcat运行后报如下错误: Illegal access: this web application instance has been stopped already ...

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

    今天在linux上的tomcat部署一个网站时,在刚启动tomcat的时候提示启动成功,然后也能访问成功. 可是第二次启动时虽然没有报错,但无法访问tomcat,查看了catalina.out日志,发 ...

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

    Tomcat,作为一个免费的服务器口碑实在太好,本想安装一个研究研究,无奈电脑是mac系统,在网上搜了一些安装方法总是出错,直到遇到了这篇博客,http://www.cnblogs.com/qingy ...

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

    本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项目一直都访问不了,看了一下日志: [root@iz8vbdzx7y7owm488t4d89z bin] ...

  5. 启动tomcat时,一直卡在Deploying web application directory

    本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项目一直都访问不了,看了一下日志: 1 2 3 4 5 6 7 [root@iz8vbdzx7y7owm ...

  6. [转载]启动tomcat时,一直卡在Deploying web application directory这块的解决方案

    转载:https://www.cnblogs.com/mycifeng/p/6972446.html 本来今天正常往服务器上扔一个tomcat 部署一个项目的, 最后再启动tomcat 的时候 发现项 ...

  7. linux启动tomcat很久或者很慢Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法

    解决方案: 找到jdk1.x.x_xx/jre/lib/security/java.security文件,在文件中找到securerandom.source这个设置项,将其改为: securerand ...

  8. Tomcat启动时卡在“INFO: Deploying web application directory ......”的解决方法

    https://blog.csdn.net/njchenyi/article/details/46641141

  9. Tomcat翻译--The Host Container

    原文:http://tomcat.apache.org/tomcat-7.0-doc/config/host.html Introduction(介绍) The Host element repres ...

随机推荐

  1. oracle查询表信息(索引,外键,列等)

    oracle中查询表的信息,包括表名,字段名,字段类型,主键,外键唯一性约束信息,索引信息查询SQL如下,希望对大家有所帮助:1.查询出所有的用户表 select * from user_tables ...

  2. hibernate_validator_07

    一.校验组序列 默认情况下,约束的验证是没有一定的顺序的,不管他们是属于哪个认证组的.但是在有些环境中,我们控制这些约束验证的顺序还是很有用的. 就拿我们上一个例子来说,我们可以这样:首先在我们检查车 ...

  3. Spring 环境搭建

    1.导包 2.编写Helloworld程序 package cn.test.helloWorld; public class HelloWorld { public void sayHello(){ ...

  4. zookeeper集群一次性启动

    编写shell脚本 新建文本,命名为start-zookeeper.sh #!/bin/sh echo "start zkServer…" for i in master work ...

  5. 几种常见ECG数据格式及对比

    SCP.DICOM.HL7aECG.GDF格式及对比 本文档首先给出SCP.DICOM.HL7aECG.GDF四种心电信号格式的具体数据结构,然后分析其各自的特点及适用范围. 一.SCP-ECG fo ...

  6. mysql for linux 数据库的安装过程

    mysql for linux 数据库的安装过程 l  安装版本:mysql-advanced-5.6.12-linux-glibc2.5-x86_64.tar.gz ,此版本是绿色版本,只需要将其解 ...

  7. [UML]UML中几种类间关系

    UML中类间关系主要有六种,分别是继承.实现.依赖.关联.聚合.组合 1.继承 继承是指A类继承B类,继承它private除外的所有属性和方法,这种关系是最常见的关系,在java中使用extends表 ...

  8. [PHP学习日志]简单Session的使用

    首先,给出一些Session的解释:目前最实用的网络协议即HTTP超文本传输协议,它是“无状态”的,所谓“无状态”是指它在用户与服务器交互时没有存储需要交互的“状态”.而Session 是在网络应用中 ...

  9. 在linux下将当前目录文件全部小写含目录名

    ls | sed -n '/[A-Z]/s/.*/mv & \L&/e' 公司以前用的windows server 服务器  文件大小写都一样.  新迁移到centos 服务器上,发现 ...

  10. 如何编写pythonGNURADIO应用

    三个基本概念: flow graph 很大一部分GNURADIO程序就是一个流图.流图包括若干信号处理模块(BLock),以及一些用表示数据流的边. BLock 所有信号处理过程在block中进行.在 ...