tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DIGLLOYD INC <digllo...@diglloyd.com>
Subject Re: simple JSP redirect to another page -- how to deal with relative URLs
Date Fri, 25 Apr 2008 20:15:24 GMT
Thanks, I've tried that.  Including with a full path still makes the  
included file relative to the directory in which the jsp resides.


On Apr 25, 2008, at 1:02 PM, David Smith wrote:

> I see the problem.  You could use absolute paths in jsp includes and  
> the servlet container would understand them as relative to the  
> webapp's root as opposed to the server's root:
>
> Say you have this file layout
>
> webapp
> |    index.jsp
> |    article1
> |        index.jsp
> |        article1.html
> |    article2
> |        index.jsp
> |        article1.html
>
> article2/index.jsp could simply have <jsp:include file="/article1/ 
> article1.html" /> and it would find article1.html in the article1  
> folder.
>
> --David
>
> DIGLLOYD INC wrote:
>> I previously asked about remapping URLs and got some helpful  
>> responses. In a nutshell, this was recommended:
>> http://tuckey.org/urlrewrite/
>>
>> Looks very good for some purposes.
>>
>> But I also want to solve a much simpler problem--
>>
>> I have a very large amount of static content (articles), with each  
>> article in its own directory.  A main Table of Contents links to  
>> the start page in each directory, which is *not* index.html (eg  
>> some-main-page.html).  I don't want to rename or change those pages  
>> as they have world-wide direct links to them--they have to stay as- 
>> is.  But I do want to insert an index.jsp page without altering any  
>> content.
>>
>> For many of these folders inserting a trival index.jsp solves the  
>> index-page problem:
>> <%@ include file="the-main-page.html" %>
>>
>> (though I do wonder if google consider this unacceptable duplicate  
>> content)
>>
>> My pages all use relative links eg "..", "./", etc.  So this works  
>> ***when the page being included is in the same directory**.
>>
>> But when the include page is in another directory, none of the  
>> relative links work.  None of these variants do the right thing;  
>> any referenced images cannot be found.
>>
>> <%@ include  file="../ReviewInfo.html" %>
>> <jsp:include file="../ReviewInfo.html" %>
>> <jsp:forward page="../some-other-page.html" />
>>
>> The jsp:forward directive seems perfect, but the flaw of not  
>> changing the current location (eg no "cd" is done first) makes it  
>> useless for this purpose.  Or does it?  Is there something I'm  
>> missing here?
>>
>> Alternately, is there some other trivial solution?
>>
>> URL-rewriting is not appropriate in this case; there is no  
>> particular pattern, just a fair number of specific cases.  I was  
>> hoping for a simple 1-line index.jsp in each directory.
>>
>> Lloyd
>>
>>
>> Lloyd Chambers
>> http://diglloyd.com
>>
>> [Mac OS X 10.5.2 Intel, Tomcat 6.0.16]
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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
>

Lloyd Chambers
http://diglloyd.com

[Mac OS X 10.5.2 Intel, Tomcat 6.0.16]





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


Mime
View raw message