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:00:26 GMT
David,

Yes, I understand how relative paths work.

The problem is that the jsp include directives:
- include an html page that is *not* in the same directory as the jsp  
page;
- the relative links in the included html file are supposed to be  
relative to their own directory not the directory of the JSP.

eg:
/foo/bar/index.jsp
/foo/some-page.html

index.jsp contains
<jsp:forward page="../some-page.html" />

This doesn't work; a link "images/foo.jpg" in some-page.html ends up  
being /foo/bar/images/foo.jpg instead of /foo/images/foo.jpg.

Lloyd

On Apr 25, 2008, at 12:40 PM, David kerber wrote:

> 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.
> Your examples may be simplified from the real thing, but remember  
> what the .'s mean:  a single one means the current folder, and a  
> double means the parent of the current folder.  So get into another  
> directory at the same level (both subfolders of the same parent  
> folder), you need to go up with the double dot, and then back down  
> into the other folder.  For example, if you are in folder B, which  
> is a subfolder of A, and you want to get into C, which is also a  
> subfolder of A, you need to do:  ../C/myotherpage.html.
>
> HTH
> D
>
>
>
> ---------------------------------------------------------------------
> 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