You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Vernon _ <vw...@hotmail.com> on 2006/11/06 22:10:23 UTC

Application Path

I have another new application deployed in a non-root directory. I need to 
have absolute paths for CSS and Javascript in order to import them properly 
with differenct level structure of JSP files. I can deploy it as the root 
application or add the application name in the absolute path. Neither 
solutions are very good. Any good practise to solve this issue?

Thanks,

Vernon

_________________________________________________________________
Find a local pizza place, music store, museum and more…then map the best 
route!  http://local.live.com?FORM=MGA001


---------------------------------------------------------------------
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


Re: Application Path

Posted by Harry <ha...@mantheakis.freeserve.co.uk>.
Using the BASE tag means that you only need to change that one single value
- all the other URLs in your pages would stay fixed, because they are
relative to the BASE tag.

So, for example, you could have a common tag library that sets the BASE tag
value dynamically for all your pages - IOW, one tag library services all
your pages.

As for altering the code between development and deployment, the solutions
to that are trivial: if you are rebuilding between development and
deployment, then use a different build property to set a runtime property
that your tag library references.

If you're using the same build, then have a runtime variable that you can
set, which you tag library references.

I've used this method, and I recommend it. It's simple, and portable.

Harry Mantheakis

> Thanks for all your information.
> 
> I was thinking of a application configuration solution so that I don't need
> to alter the code between development and deployment. I have several
> applications in various development phases in my box. I try to figure to
> handle them together.
> 
> 
> Vernon
> __________________________________________________________
> http://www.vicina.info
> 
> 
> ----Original Message Follows----
> From: Harry <ha...@mantheakis.freeserve.co.uk>
> Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
> To: Tomcat Users List <us...@tomcat.apache.org>
> Subject: Re: Application Path
> Date: Tue, 07 Nov 2006 09:31:27 +0000
> MIME-Version: 1.0
> Received: from mail.apache.org ([140.211.11.2]) by
> bay0-mc9-f5.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Tue, 7
> Nov 2006 01:31:58 -0800
> Received: (qmail 18223 invoked by uid 500); 7 Nov 2006 09:32:06 -0000
> Received: (qmail 18212 invoked by uid 99); 7 Nov 2006 09:32:06 -0000
> Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133)
> by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2006 01:32:06 -0800
> Received: neutral (herse.apache.org: local policy)
> Received: from [80.168.70.142] (HELO relay2.mail.uk.clara.net)
> (80.168.70.142)    by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2006
> 01:31:51 -0800
> Received: from mantheakis.claranet.co.uk ([80.168.130.24] helo=[10.0.0.3])by
> relay2.mail.uk.clara.net with esmtp (Exim 4.50)id 1GhNIn-0007na-7mfor
> users@tomcat.apache.org; Tue, 07 Nov 2006 09:31:29 +0000
> X-Message-Info: txF49lGdW42h0cbO+nEGCm+Gy+i+Lt7qOV5pel0LBy8=
> Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm
> Precedence: bulk
> List-Help: <ma...@tomcat.apache.org>
> List-Unsubscribe: <ma...@tomcat.apache.org>
> List-Post: <ma...@tomcat.apache.org>
> List-Id: <users.tomcat.apache.org>
> Delivered-To: mailing list users@tomcat.apache.org
> X-ASF-Spam-Status: No, hits=0.5 required=10.0tests=DNS_FROM_RFC_ABUSE
> X-Spam-Check-By: apache.org
> User-Agent: Microsoft-Entourage/10.1.6.040913.0
> X-Virus-Checked: Checked by ClamAV on apache.org
> Return-Path: users-return-153735-vwu0=hotmail.com@tomcat.apache.org
> X-OriginalArrivalTime: 07 Nov 2006 09:31:58.0422 (UTC)
> FILETIME=[92575F60:01C7024F]
> 
> Alternatively, you can set a BASE reference within the HEAD element of each
> page, and then use relative-paths in all your URLs:
> 
> 
> <head>
>    ...
>    <base href="http://www.webadorable.com/your-app-context-name-here/"/>
>    ...
> </head>
> 
> ...
> 
> <img src="relpath/to/image.jpg"/>
> 
> 
> The BASE value can (should!) be set dynamically, of course - with a tag
> library, or whatever.
> 
> Notice that the BASE reference has a trailing slash, whilst your relative
> paths must start without a leading slash.
> 
> Harry Mantheakis
> 
> 
>> Is there any reason you can't just have the paths composed dynamically?:
>> 
>> <img src="${pageContext.request.contextPath}/webapp/relpath/to/image.jpg"
> />
>> 
>> For the ROOT webapp, the expression will return an empty path, so it's
>> always correct.
>> 
>> --David
>> 
>> Vernon _ wrote:
>>> 
>>> I have another new application deployed in a non-root directory. I
>>> need to have absolute paths for CSS and Javascript in order to import
>>> them properly with differenct level structure of JSP files. I can
>>> deploy it as the root application or add the application name in the
>>> absolute path. Neither solutions are very good. Any good practise to
>>> solve this issue?
>>> 
>>> Thanks,
>>> 
>>> Vernon
>>> 
>>> _________________________________________________________________
>>> Find a local pizza place, music store, museum and moreŠthen map the
>>> best route! http://local.live.com?FORM=MGA001
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> 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
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
>> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> _________________________________________________________________
> Stay in touch with old friends and meet new ones with Windows Live Spaces
> http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://space
> s.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
> 
> 


---------------------------------------------------------------------
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


Re: Application Path

Posted by Vernon _ <vw...@hotmail.com>.
Thanks for all your information.

I was thinking of a application configuration solution so that I don't need 
to alter the code between development and deployment. I have several 
applications in various development phases in my box. I try to figure to 
handle them together.


Vernon
__________________________________________________________
http://www.vicina.info


----Original Message Follows----
From: Harry <ha...@mantheakis.freeserve.co.uk>
Reply-To: "Tomcat Users List" <us...@tomcat.apache.org>
To: Tomcat Users List <us...@tomcat.apache.org>
Subject: Re: Application Path
Date: Tue, 07 Nov 2006 09:31:27 +0000
MIME-Version: 1.0
Received: from mail.apache.org ([140.211.11.2]) by 
bay0-mc9-f5.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2444); Tue, 7 
Nov 2006 01:31:58 -0800
Received: (qmail 18223 invoked by uid 500); 7 Nov 2006 09:32:06 -0000
Received: (qmail 18212 invoked by uid 99); 7 Nov 2006 09:32:06 -0000
Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133)    
by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2006 01:32:06 -0800
Received: neutral (herse.apache.org: local policy)
Received: from [80.168.70.142] (HELO relay2.mail.uk.clara.net) 
(80.168.70.142)    by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Nov 2006 
01:31:51 -0800
Received: from mantheakis.claranet.co.uk ([80.168.130.24] helo=[10.0.0.3])by 
relay2.mail.uk.clara.net with esmtp (Exim 4.50)id 1GhNIn-0007na-7mfor 
users@tomcat.apache.org; Tue, 07 Nov 2006 09:31:29 +0000
X-Message-Info: txF49lGdW42h0cbO+nEGCm+Gy+i+Lt7qOV5pel0LBy8=
Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm
Precedence: bulk
List-Help: <ma...@tomcat.apache.org>
List-Unsubscribe: <ma...@tomcat.apache.org>
List-Post: <ma...@tomcat.apache.org>
List-Id: <users.tomcat.apache.org>
Delivered-To: mailing list users@tomcat.apache.org
X-ASF-Spam-Status: No, hits=0.5 required=10.0tests=DNS_FROM_RFC_ABUSE
X-Spam-Check-By: apache.org
User-Agent: Microsoft-Entourage/10.1.6.040913.0
X-Virus-Checked: Checked by ClamAV on apache.org
Return-Path: users-return-153735-vwu0=hotmail.com@tomcat.apache.org
X-OriginalArrivalTime: 07 Nov 2006 09:31:58.0422 (UTC) 
FILETIME=[92575F60:01C7024F]

Alternatively, you can set a BASE reference within the HEAD element of each
page, and then use relative-paths in all your URLs:


<head>
     ...
     <base href="http://www.webadorable.com/your-app-context-name-here/"/>
     ...
</head>

...

<img src="relpath/to/image.jpg"/>


The BASE value can (should!) be set dynamically, of course - with a tag
library, or whatever.

Notice that the BASE reference has a trailing slash, whilst your relative
paths must start without a leading slash.

Harry Mantheakis


 > Is there any reason you can't just have the paths composed dynamically?:
 >
 > <img src="${pageContext.request.contextPath}/webapp/relpath/to/image.jpg" 
/>
 >
 > For the ROOT webapp, the expression will return an empty path, so it's
 > always correct.
 >
 > --David
 >
 > Vernon _ wrote:
 >>
 >> I have another new application deployed in a non-root directory. I
 >> need to have absolute paths for CSS and Javascript in order to import
 >> them properly with differenct level structure of JSP files. I can
 >> deploy it as the root application or add the application name in the
 >> absolute path. Neither solutions are very good. Any good practise to
 >> solve this issue?
 >>
 >> Thanks,
 >>
 >> Vernon
 >>
 >> _________________________________________________________________
 >> Find a local pizza place, music store, museum and moreŠthen map the
 >> best route! http://local.live.com?FORM=MGA001
 >>
 >>
 >> ---------------------------------------------------------------------
 >> 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
 >>
 >
 >
 > ---------------------------------------------------------------------
 > 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
 >
 >


---------------------------------------------------------------------
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

_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces 
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us


---------------------------------------------------------------------
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


Re: Application Path

Posted by Harry <ha...@mantheakis.freeserve.co.uk>.
Alternatively, you can set a BASE reference within the HEAD element of each
page, and then use relative-paths in all your URLs:


<head>
    ...
    <base href="http://www.webadorable.com/your-app-context-name-here/"/>
    ...
</head>

...

<img src="relpath/to/image.jpg"/>


The BASE value can (should!) be set dynamically, of course - with a tag
library, or whatever.

Notice that the BASE reference has a trailing slash, whilst your relative
paths must start without a leading slash.

Harry Mantheakis


> Is there any reason you can't just have the paths composed dynamically?:
> 
> <img src="${pageContext.request.contextPath}/webapp/relpath/to/image.jpg" />
> 
> For the ROOT webapp, the expression will return an empty path, so it's
> always correct.
> 
> --David
> 
> Vernon _ wrote:
>> 
>> I have another new application deployed in a non-root directory. I
>> need to have absolute paths for CSS and Javascript in order to import
>> them properly with differenct level structure of JSP files. I can
>> deploy it as the root application or add the application name in the
>> absolute path. Neither solutions are very good. Any good practise to
>> solve this issue?
>> 
>> Thanks,
>> 
>> Vernon
>> 
>> _________________________________________________________________
>> Find a local pizza place, music store, museum and moreŠthen map the
>> best route! http://local.live.com?FORM=MGA001
>> 
>> 
>> ---------------------------------------------------------------------
>> 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
>> 
> 
> 
> ---------------------------------------------------------------------
> 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
> 
> 


---------------------------------------------------------------------
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


Re: Application Path

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vernon,

> That can solve the problem. However, is it little silly to prefix
> ${pageContext.request.contextPath} into every single URLs in the JSP files?

It's not silly if that's what you want.

Some frameworks provide either JSP taglibs or some other mechanism for
essentially allowing the framework to do that work for you. For
instance, I use struts and velocity as my framework and content
generation tools. The velocity-tools project includes "tools" that allow
me to get velocity to work very well with both the servlet container and
struts. For instance, many of my links look like this:

<a href="$link.setRelative('/relative/path/foo.do')">blah blah</a>

The "link" tool knows that it should always put the context path of the
currently executing webapp before the relative URI that I gave it. Of
course, it has all kinds of other nice things that interact with struts,
too, like being able to use named URIs instead of explicit ones, so I
can change them in a single place and not have to go changing every file
that references it.

That was a long way out of the way, but I figured it was worth
mentioning. I'm not saying that you should switch to struts or anything
like that. I'm just saying that this is the way the servlet world works,
and that many frameworks provide tools for getting around the
"silliness" you describe.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFT84e9CaO5/Lv0PARArDRAJ9aTaoR/LSQrSlVXIat9oQLbl7joACgt6SH
Gk6ht8ZQqlf5bahCkW3KDCE=
=fBO5
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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


Re: Application Path

Posted by Vernon _ <vw...@hotmail.com>.
That can solve the problem. However, is it little silly to prefix 
${pageContext.request.contextPath} into every single URLs in the JSP files?


Vernon
__________________________________________________________________________
Your local community information service - news, blogs, classifieds 
http://www.vicina.info



>Is there any reason you can't just have the paths composed dynamically?:

><img src="${pageContext.request.contextPath}/webapp/relpath/to/image.jpg" 
>/>

>For the ROOT webapp, the expression will return an empty path, so it's 
>always correct.

>--David

Vernon _ wrote:
>
>I have another new application deployed in a non-root directory. I need to 
>have absolute paths for CSS and Javascript in order to import them properly 
>with differenct level structure of JSP files. I can deploy it as the root 
>application or add the application name in the absolute path. Neither 
>solutions are very good. Any good practise to solve this issue?
>
>Thanks,
>
>Vernon
>
>_________________________________________________________________
>Find a local pizza place, music store, museum and more…then map the best 
>route! http://local.live.com?FORM=MGA001
>
>
>---------------------------------------------------------------------
>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
>


---------------------------------------------------------------------
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

_________________________________________________________________
Try the next generation of search with Windows Live Search today!  
http://imagine-windowslive.com/minisites/searchlaunch/?locale=en-us&source=hmtagline


---------------------------------------------------------------------
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


Re: Application Path

Posted by David Smith <dn...@cornell.edu>.
Is there any reason you can't just have the paths composed dynamically?:

<img src="${pageContext.request.contextPath}/webapp/relpath/to/image.jpg" />

For the ROOT webapp, the expression will return an empty path, so it's 
always correct.

--David

Vernon _ wrote:
>
> I have another new application deployed in a non-root directory. I 
> need to have absolute paths for CSS and Javascript in order to import 
> them properly with differenct level structure of JSP files. I can 
> deploy it as the root application or add the application name in the 
> absolute path. Neither solutions are very good. Any good practise to 
> solve this issue?
>
> Thanks,
>
> Vernon
>
> _________________________________________________________________
> Find a local pizza place, music store, museum and more…then map the 
> best route! http://local.live.com?FORM=MGA001
>
>
> ---------------------------------------------------------------------
> 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
>


---------------------------------------------------------------------
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