Question:

I apologize if this is a poor question, but I'm using Windows and looking to see if there's a way to run a webapp via Tomcat where the docBase is multiple folders.

A little more background is that we have our Eclipse project set up in a way that the web content is broken into separate folders. One folder represents what our SDK provides, one is a folder which has SDK patches, and a third is the project-specific components -- either of the last two folders could have subfolders/files that "erase" items from the first two.

I'd like to try and have my context file point back into my dev environment so that I don't need to build/deploy in order to see the changes I'm making. Is this possible?

A couple other notes:

  • We thought about using symlinks via mklink, but didn't want to create complexity if simplicity was out there.
  • This is just for running locally so simple hacks would be allowed. When we create the WAR which gets deployed to the real environment the ANT script creates a single web root.

Answer 1:

I use it this way:

    <Context docBase="jquery"                path="/js/jquery" />
<Context docBase="foobar/www/javascript" path="/js" />
<Context docBase="foobar/www/css" path="/css" />
<Context docBase="foobar" path="/" />

Important for the concrete context is the path-attribute. A request is processed from top to bottom.

So a request for /css/default.css is only processed from the 3rd context.

A different order may catches a different context.

This is wrong:

    <Context docBase="foobar"                path="/" />
<Context docBase="jquery" path="/js/jquery" />
<Context docBase="foobar/www/javascript" path="/js" />
<Context docBase="foobar/www/css" path="/css" />

Because /css/default.css will be catched by the first context, not the fourth.

Edit 2013-08-10: (Not by the answer-author) It is important to note that while the above technique will work, much of it is actually incorrect. Please see comments for details.

Answer 2:

Tomcat can do this for you, you just need a little extra configuration.

You are looking for VirtualDirContext which allows you to specify a list of extraResourcePaths which will be searched (in order) for additional files. You can use that to merge static resources, JSPs, directories of JAR files, etc.

Just remember that each path you add makes every file lookup potentially take longer -- especially if the file can't be found at all.

原文:http://stackoverflow.com/questions/17738049/can-a-tomcat-docbase-span-multiple-folders/17861223#17861223

Can a Tomcat docBase span multiple folders?--转的更多相关文章

  1. Could not publish server configuration for MyEclipse Tomcat v7.0. Multiple Contexts have a path

    Could not publish server configuration for Tomcat v6.0 Server at localhost. 经常在使用tomcat服务器的时候 总会发生一些 ...

  2. tomcat docBase 和 path

    <Context docBase="zjzc-web-api" path="/api" reloadable="false"/> ...

  3. 【Tomcat】Tomcat的使用

    第一章 JDK的安装 1.1  windows下安装 1.1.1  配置环境变量 安装完成后,还要进行 Java 环境的配置,才能正常使用,步骤如下: (1)在我的电脑点击右键——〉选择属性, (2) ...

  4. Tomcat Clustering - A Step By Step Guide --转载

    Tomcat Clustering - A Step By Step Guide Apache Tomcat is a great performer on its own, but if you'r ...

  5. nginx+tomcat+memcached搭建服务器集群及负载均衡

    在实际项目中,由于用户的访问量很大的原因,往往需要同时开启多个服务器才能满足实际需求.但是同时开启多个服务又该怎么管理他们呢?怎样实现session共享呢?下面就来讲一讲如何使用tomcat+ngin ...

  6. eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“

    你的位置:首页 > Java编程 > eclipse发布项目报错:Multiple Contexts hava a path of “/xxx“ eclipse发布项目报错:Multipl ...

  7. Nginx 与Tomcat 实现动静态分离、负载均衡

    Nginx 与Tomcat 实现动静态分离.负载均衡 一.Nginx简介: Nginx一个高性能的HTTP和反向代理服务器, 具有很高的稳定性和支持热部署.模块扩展也很容易.当遇到访问的峰值,或者有人 ...

  8. Nginx+Tomcat+Memcached 实现集群部署时Session共享

    Nginx+Tomcat+Memcached 实现集群部署时Session共享 一.简介 我们系统经常要保存用户登录信息,有Cookie和Session机制,Cookie客户端保存用户信息,Sessi ...

  9. GridLayout with span

    Widgets can span multiple columns or rows in a grid. In the next example we illustrate this. #!/usr/ ...

随机推荐

  1. .net中XML的创建01(传统方法)

    XML传统的创建: 传统的创建主要是依据XmlDocument的对象展开的,通过XmlDocument对象可以创建元素(XmlElement).属性(XmlAttribute)以及文本节点(Creat ...

  2. 设置windows窗口ICON 【windows 编程】【API】【原创】

    1. ICON介绍 最近开始接触windows 编程,因此将自己所接触的一些零散的知识进行整理并记录.本文主要介绍了如何更改windows对话框窗口的ICON图标.这里首先介绍一下windows IC ...

  3. ASP.NET中实现页面间数据传递的方法

    说到页面间数据传递,很多人都会想到通过像Session这样的全局变量,但是向Session中添加的东西太多会增加服务器的压力,页面间数据传递,数据的作用范围越小越好.   ASP.NET页面间数据传递 ...

  4. MyBatis学习笔记(3)—— 利用mybatis灌入假数据

    由于第三方厂商未能按时提供实时数据,故需要纯手动导入一些实时数据,用于统计分析.正好最近自己学习了mybatis .因此使用mybatis 配置一个select.insert 的简单操作语句,用于灌入 ...

  5. javascript权威指南学习笔记1

    打开这本书,进入到javascript的世界.以前都是看各种视频,感觉什么收获也没有,反而弄得脑袋混乱,希望能够按照这本书的节奏掌握javascript这门语言,为我的前端学习打下基础. 学习前准备: ...

  6. POJ3274 hash

    POJ3274 问题重述: 已知有n头牛,用一个K位二进制数Ak,Ak-1,...,A1表示一头牛具有的特征,Ai=1表示具有特征i.现给定按顺序排列的N头牛的k位特征值,称某个连续范围内“特征平衡” ...

  7. SqlServer将数据库中的表复制到另一个数据库

    前述: 文章来自百度经验 操作: 在使用SqlServer的过程中,我们可能需要将表从一个数据库复制到另一个数据库中,今天,为大家介绍这种操作的具体方法及步骤. 复制表结构 1 首先,打开并连接Sql ...

  8. Oracle的Net Configuration Assistant 配置

    在进行团队开发的时候,一般团队的每一个人只需要安装一个客户端即可,没有必要安装一个Oracle 数据库服务器,而数据库服务器是属于共享的,此时,我们就需要配置客户端.客户端的配置可以有以下两种方式:第 ...

  9. 嵌入式linux加载引导内核和根文件系统的方法

    总体来说,嵌入式Linux内核和根文件的引导与PC机差不多.嵌入式linux内核和根文件系统可以存放在各种可能的存储设备中,一般情况下我 们将内核和根文件系统直接烧入到Flash中(包括NOR和NAN ...

  10. C#泛型总结

    泛型方法 在C#2.0中,方法可以定义特定于其执行范围的泛型参数,如下所示: public class MyClass<T>     {         //指定MyMethod方法用以执 ...