Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 45630 invoked from network); 1 May 2007 09:07:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2007 09:07:32 -0000 Received: (qmail 7685 invoked by uid 500); 1 May 2007 09:07:23 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 7656 invoked by uid 500); 1 May 2007 09:07:22 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 7645 invoked by uid 99); 1 May 2007 09:07:22 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 02:07:22 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of martin846@googlemail.com designates 66.249.92.169 as permitted sender) Received: from [66.249.92.169] (HELO ug-out-1314.google.com) (66.249.92.169) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 02:07:15 -0700 Received: by ug-out-1314.google.com with SMTP id 23so17499ugr for ; Tue, 01 May 2007 02:06:54 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=ZsM75YFvxvj/wH28gWygrI8iDH7vRQ1Aj9ugswGj2RQBU+JHF09ua5yzEyADNubzX4LJhtOyyMOwJP6R9m9W2l0rBQ3f88NUddc67OGLSupBAboJcqvkyimbG/Qxhj9dhblpX0gqH8nryfblV0rGx2hCZH7tOYvs44nbBwfxvRE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=VO9PEtrKifyvFskRad1SmeNSFOqlEFQZZu2kP4YUgEPTSRVBk5So4KqwJ/bbFLqE43vZjl8d1h9sARjOFKImpd8Mf7MS8qFnwAwNbaKy8Ybpal2LHuIjVkdfER7oRKir1bPi9ezQpWwIH1jJTPE32btDKlRvWBLHmZNwwL4uYsU= Received: by 10.66.221.6 with SMTP id t6mr205749ugg.1178010414151; Tue, 01 May 2007 02:06:54 -0700 (PDT) Received: by 10.66.226.9 with HTTP; Tue, 1 May 2007 02:06:54 -0700 (PDT) Message-ID: Date: Tue, 1 May 2007 10:06:54 +0100 From: "Martin Jones" Sender: martin846@googlemail.com To: "Tomcat Users List" Subject: Re: How to share static content across multiple tomcat webapps In-Reply-To: <3ef28230704300753t723e3fbdt7783d98d8eeb5a5c@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3ef28230704300753t723e3fbdt7783d98d8eeb5a5c@mail.gmail.com> X-Google-Sender-Auth: 8845d14824780f68 X-Virus-Checked: Checked by ClamAV on apache.org Thanks for the reply. After mulling this over, I've thought of another way to do it (apologies if I'm not using the correct terminology here). Have the static content in a single directory on my development machine, then use my Ant build script to have the contents included in the .war file. Then, when I make any changes to the static content, I just have to rebuild and redeploy .war files for each webapp I'm running. There would be multiple copies of sidebar.html and images, etc. on the server, but that wouldn't matter as I would never edit them directly. This seems like a good compromise - any thoughts? Thanks, Martin On 4/30/07, Rashmi Rubdi wrote: > Hi Martin, > > On 4/30/07, Martin Jones wrote: > > Hi, > > > > This seems like an obvious question but I'd appreciate any answers. I > > have several webapps running under tomcat that need to be able to > > include the same sidebar in their .jps. if the sidebar is within the > > context, this works fine: > > > > <%@ include file="sidebar.html" %> > > > > However this requires me to keep a copy of sidebar.html (and all the > > images) in each .war. I'd rather keep a single copy of sidebar.html. > > If I make a new context "static" in tomcat and place the sidebar + > > images there, I can access it fine in my browser with the url: > > > > http://localhost:8080/static/sidebar.html > > > > but the naive change to the jsp: > > > > <%@ include file="../static/sidebar.html" %> > > The include directive is out of the question because according to it's syntax > http://java.sun.com/products/jsp/syntax/2.0/syntaxref209.html#1003408 > it only accepts URLs that are relative to the web application (a.k.a Context). > > > > fails with "the path specifies a resource outside the web > > application". Using jstl and import: > > > > > > JSTL's c:import tag has an attribute called context, > http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/c/import.html > which allows one to access resources from other contexts (a.k.a web > applications) , however in order to function properly the crossContext > attribute of the web application's Context node must be enabled (set > to true). > > From my experience setting crossContext to true has caused other > conflicts when 2 resources (Java Classes) have the same name in 2 > different web applications that have crossContext enabled ---- it > could be that there was something wrong in my configuration. But, I'm > just letting you know about it. > > > > > leads to: > > > > javax.servlet.jsp.JspTagException: /../static/sidebar.html > > > > However, if I use the absolute path: > > > > > > > > the page is fine, but because the paths to the images are copied > > directly from sidebar.html and included in the .jsp they are > > incorrect. > > In this case you would also need to change the URLs of the images to > be the absolute URL. > > > > > It seems to me that what I'm trying to accomplish is a fairly common > > thing; I'd appreciate any pointers. > > Normally it is considered bad practice to hardcode the entire URL, you > may want to store the domain etc in a constant and prefix it to the > rest of the URL. > > Also, there might be better ways to accomplish this. > > I don't know much about JNDI but it comes to mind, is it possible to > store images as a global JNDI resource. > > > Thanks, > > > > Martin > > > > -Regards > Rashmi > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > -- Martin Jones Bioinformatics Team Centres for Cardiovascular Science and Inflammation Research, University of Edinburgh, Queen's Medical Research Institute, 47 Little France Crescent Edinburgh EH16 4TJ United Kingdom T: +44 131 242 6700 --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org