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. Swift - 26 - 函数的基础写法

    //: Playground - noun: a place where people can play import UIKit // 无参无返回 // -> Void可以省略不写, 或者写成 ...

  2. 自动Telnet远程登陆命令

    有些时候,在面对开发机的时候,不断的telnet和不断的command自己的命令确实非常麻烦,需要一些自动测试或者自动部署的需求.然而面对telnet很多同学都跟我一样一开始觉得无法通过管道等传用户名 ...

  3. 利用GDB在远程开发机进行调试

    由于一些环境的制约,很多同学都可能需要在开发机上进行调试,但由于开发机资源的限制,在开发机上直接进行本地的GDB环境配置就成了难题,这个时候其实我们可以利用GDB中自带的gdbserver工具就可以进 ...

  4. C# Trim方法去除字符串两端的指定字符

    var str= ",2,3,4,6,7,"; var str2 = str.Trim(new char[] { ',' }); //去除字符串str两端的','字符. //则st ...

  5. Unity扩展编辑器--类型3:Custom Editors

    Custom Editors 加速游戏制作过程的关键是为哪些频繁使用的组件创建自定义的编辑器,为了举例,我们将会使用下面这个极其简单的脚本进行讲解,它的作用是始终保持一个对象注视某一点. public ...

  6. centos和Ubuntu区别

    centos中新建的非root用户是没有sudo的权限的,如果需要使用sudo权限必须在/etc/sudoers 中加入账户和权限,所以切换到root账号的时候只需要输入:su,加入root账号的密码 ...

  7. tornado项目

    tornado项目之基于领域驱动模型架构设计的京东用户管理后台 本博文将一步步揭秘京东等大型网站的领域驱动模型,致力于让读者完全掌握这种网络架构中的“高富帅”. 一.预备知识: 1.接口: pytho ...

  8. Node.js 入门(2)

    1.http 请求 //调用Node.js自带的http模块 var http = require("http"); //调用http模块提供的函数createServer htt ...

  9. 【Maven实战】传递性依赖的问题

    在上一篇文章中我们已经介绍了依赖性,这次我们再来介绍下传递依赖的问题,首先我们还是在上篇文章基础之上进行编写. 1.上篇文章中已经建立了一个user-core的模块,现在首先再建立一个user-log ...

  10. 《how to design programs》13章用list构造表

    使用cons构造一个包含多个元素的表十分麻烦,因此scheme提供了list操作,该操作接受任意量的值作为输入以创建一个表,下面是扩展的语法: <prm>=list 扩展的scheme值的 ...