File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes include a file between webapps Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "include a file between webapps" Watch "include a file between webapps" New topic

include a file between webapps

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I have a header file which I'd like to share between multiple webapps. Is this possible? The directory structure is below:


It seems silly to have to duplicate the header.jsp file just because these are in different webapps. Especially since I'm using single sign on. But none of the below work:

Am I going to be forced to duplicate this header.jsp page?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

It seems silly to have to duplicate the header.jsp file just because these are in different webapps.

Sorry, but silly as it may seem to you, sharing resources across webapps is not a good idea. As you have seen, the mechanisms inherent in web application containers (as outlined in the specifications) focus heavily on making web applications self-contained units.

Trying to create artificial bindings between discrete web applications is not only technically difficult (because you are bucking the intentions of the specifications), but is just bad architectural design as it creates artificial dependencies between the apps.

Rather, you can have a single source for the shared resource, but copy it to each web application as necessary during the automated build process. This way, you manage the shared resource at build time, rather than trying to do so with execution-time mechanisms.
[ August 18, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: include a file between webapps
jQuery in Action, 3rd edition