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. iOS开发中常用的宏

    前言 今天将一些简化工程代码的宏定义拿出来分享一下,自定义一些宏可以有效的简化代码,提高编码效率. Application #define APPLICATION [UIApplication sha ...

  2. 关于线程池ThreadPool的学习

    学习重点ThreadPool.SetMinThreads(out workerThreads, out completionPortThreads).这是整个线程池的关键.  而ThreadPool. ...

  3. Hibernate 性能优化之二级缓存

    二级缓存是一个共享缓存,在二级缓存中存放的数据是共享数据特性     修改不能特别频繁     数据可以公开二级缓存在sessionFactory中,因为sessionFactory本身是线程安全,所 ...

  4. php中session的运行机制

    在PHP中session默认是以文件的形式存储于服务器的 而客户端和服务端则是通过session_id来完成握手的,默认情况下PHP会将session_id存储于cookie中,用户每次请求时该ses ...

  5. Linux命令学习计划【sed】

    引言: Sed命令是linux里用于文本行处理的命令. 为了便于说明,我在/usr/dict下创建了字典words并以此作为演示模板 先用nl 打印下words内容: *打印篇: Q1:如何打印某一行 ...

  6. jquery mobile navbar

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...

  7. java获得系统当前日期

    package com.web.test; import java.text.ParseException; import java.text.SimpleDateFormat; import jav ...

  8. 数据结构 --- 线性表学习(php模拟)

    线性表:零个或多个数据元素的有限序列(注:以下都是用的整型数据模拟) 一 顺序存储结构(用一段地址连续的存储单元一次存储线性表的数据元素) 1.1 三个属性:存储空间的起始位置:最大存储容量:当前长度 ...

  9. 如何去除 ckeditor 上传图片后在原码中留下的 style="width: 100%;height:100px"之类的代码呢?

    ckeditor编辑器在上传图片的时候,会神奇的加上一段诡异的代码: 这导致上传的小图也是被拉伸到100%,我根本就没有定义它,找来找去也找不到element.style,原来这是在system.cs ...

  10. 2-16 HDO1106

    这题寒假也没搞出来,但今天花了一小时终于搞定. 题意是输入一串数字字符,把‘5’当作空格,然后把被分割开的数字进行排序输出. 首先是字符串输入,按照高精度的处理方法,数值低位放到数组低位.(字符串型的 ...