You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nathan Coast <na...@cableinet.co.uk> on 2001/05/10 10:54:25 UTC
relative urls
Hi,
I've got an app that will be deployed to a number of different contexts
/test
/dev
/staging
/
(root)
The app contains a large amount of static content e.g. images which will always
be referenced from "/current_context/image"
some of the jsps are accessed directly and via the action servlet - sometimes
with different depths for the action url e.g.
/current_context/something/something_else/my_action.do
/current_context/something/another_action.do
/somepage.jsp
this obviously rules out using relative urls for the static content but the
changing contexts makes it difficult for basing the urls on root.
Is the solution to precede the url to every image in every jsp with a variable
containing the value of the context? Is this not a performance hit? What's the
best way to do it? Is there a struts tag that does this for me? How do I achieve
world peace? - oops wrong mail list.
Thanks
Nathan
Re: relative urls
Posted by Nathan Coast <na...@cableinet.co.uk>.
cheers
this is what I figured, seems like an unpleasant overhead object - instantiation
and 3 method calls for every relative url in the site every time every page is
accessed.
Must be some hack to get the context and place it into a static final variable
somewhere prior to jsp compilation. This would effectively compile the variable
value into every jsp. Any ideas?
Scott Walter wrote:
> I ran into this same issue. I accomplished this by
> creating a custom tag (in my case called, PageLoader).
> The PageLoader tag will expose a scripting variable
> called contextRoot, which is basically
> pageContext.getRequest()).getContextPath()
>
> scott.
> --- Nathan Coast <na...@cableinet.co.uk> wrote:
>
>> Hi,
>>
>> I've got an app that will be deployed to a number of
>> different contexts
>>
>> /test
>> /dev
>> /staging
>> /
>> (root)
>>
>> The app contains a large amount of static content
>> e.g. images which will always
>> be referenced from "/current_context/image"
>>
>> some of the jsps are accessed directly and via the
>> action servlet - sometimes
>> with different depths for the action url e.g.
>>
>
> /current_context/something/something_else/my_action.do
>
>> /current_context/something/another_action.do
>> /somepage.jsp
>>
>> this obviously rules out using relative urls for the
>> static content but the
>> changing contexts makes it difficult for basing the
>> urls on root.
>>
>> Is the solution to precede the url to every image in
>> every jsp with a variable
>> containing the value of the context? Is this not a
>> performance hit? What's the
>> best way to do it? Is there a struts tag that does
>> this for me? How do I achieve
>> world peace? - oops wrong mail list.
>>
>> Thanks
>> Nathan
>>
>
>
>
> =====
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Scott
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
Re: relative urls
Posted by Scott Walter <tx...@yahoo.com>.
I ran into this same issue. I accomplished this by
creating a custom tag (in my case called, PageLoader).
The PageLoader tag will expose a scripting variable
called contextRoot, which is basically
pageContext.getRequest()).getContextPath()
scott.
--- Nathan Coast <na...@cableinet.co.uk> wrote:
> Hi,
>
> I've got an app that will be deployed to a number of
> different contexts
>
> /test
> /dev
> /staging
> /
> (root)
>
> The app contains a large amount of static content
> e.g. images which will always
> be referenced from "/current_context/image"
>
> some of the jsps are accessed directly and via the
> action servlet - sometimes
> with different depths for the action url e.g.
>
/current_context/something/something_else/my_action.do
> /current_context/something/another_action.do
> /somepage.jsp
>
> this obviously rules out using relative urls for the
> static content but the
> changing contexts makes it difficult for basing the
> urls on root.
>
> Is the solution to precede the url to every image in
> every jsp with a variable
> containing the value of the context? Is this not a
> performance hit? What's the
> best way to do it? Is there a struts tag that does
> this for me? How do I achieve
> world peace? - oops wrong mail list.
>
> Thanks
> Nathan
>
=====
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Scott
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/