You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by DIGLLOYD INC <di...@diglloyd.com> on 2008/04/25 21:27:00 UTC

simple JSP redirect to another page -- how to deal with relative URLs

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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by Hassan Schroeder <ha...@gmail.com>.
On Fri, Apr 25, 2008 at 1:12 PM, DIGLLOYD INC <di...@diglloyd.com> wrote:

>  As I said there are other issues.  Making them fixed paths would mean I
> couldn't edit them, copy them (for revisions, etc) without having to fix up
> numerous pages.

Right, it's work to fix them -- but you're spending time and effort now
to find a way to work around a standard JSP behavior. Fix 'em once,
do it the right way from now on, you're golden :-)

> And the uses are not only when routed through a web server.

Not sure what that means, but...

FWIW!
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
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: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
Hassan,

As I said there are other issues.  Making them fixed paths would mean  
I couldn't edit them, copy them (for revisions, etc) without having to  
fix up numerous pages.  And the uses are not only when routed through  
a web server.

Lloyd

On Apr 25, 2008, at 1:08 PM, Hassan Schroeder wrote:

> On Fri, Apr 25, 2008 at 1:00 PM, DIGLLOYD INC  
> <di...@diglloyd.com> wrote:
>>
>> The problem is that the jsp include directives:
>> - include an html page that is *not* in the same directory as the  
>> jsp page;
>
> I've never -- and that's a long time, web-wise :-) -- liked relative  
> paths
> for this reason, among others.
>
> If I were you I'd bite the bullet and fix 'em once and for all.
>
> -- 
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
>
> ---------------------------------------------------------------------
> 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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by Hassan Schroeder <ha...@gmail.com>.
On Fri, Apr 25, 2008 at 1:00 PM, DIGLLOYD INC <di...@diglloyd.com> wrote:
>
>  The problem is that the jsp include directives:
>  - include an html page that is *not* in the same directory as the jsp page;

I've never -- and that's a long time, web-wise :-) -- liked relative paths
for this reason, among others.

If I were you I'd bite the bullet and fix 'em once and for all.

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
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: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by David kerber <dc...@verizon.net>.
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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by Bill Barker <wb...@wilshire.com>.
"DIGLLOYD INC" <di...@diglloyd.com> wrote in message 
news:C2A0AF74-F8EA-468C-9E97-64A0EA53FA08@diglloyd.com...
> Christopher,
>
> Well, I'm not a web expert, so if there's a better way (redirect) I'm  all 
> ears.
>
> From what I can find by googling, redirects have a slew of issues of 
> their own. But I'm a newbie at this, so I might be misunderstanding.
>
> How would I do a redirect in Tomcat for my stated issue, keeping in  mind 
> that doing so is case-by-case, not a nice regexp pattern.
>

If I were given this problem, I'd probably write a Filter that uses a 
properties files to resolve references.  Something like:

    public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain)
    throws IOException, ServletException {
         if(request instanceof HttpServletRequest && response instanceof 
HttpServletResponse) {
              HttpServletRequest hrequest = (HttpServletRequest)request;
              HttpServletResponse hresponse = (HttpServletResponse)response;
              String req = hrequest.getServletPath();
              if(req.length() > 0)
                    req = req.substring(1).replace('/','.');
              String where = map.get(req);
              if(where != null) {
                   hresponse.sendRedirect(where);
                   return;
             }
        }
        chain.doFilter(request, response);
    }

> Lloyd
>
> On Apr 25, 2008, at 1:05 PM, Christopher Schultz wrote:
>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Lloyd,
>>
>> DIGLLOYD INC wrote:
>> | 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" />
>>
>> This is a very weird way to do things. You should either generate
>> content /or/ forward. Why are you doing both?
>>
>> Instead of using a forward, why not do a redirect? That way, the new
>> request has the correct URL and your relative paths should be correct.
>>
>> - -chris
>>
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.9 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAkgSOW4ACgkQ9CaO5/Lv0PCZtgCgwMQ2Nq53WFJV1qA2UtOVT62P
>> aroAoLf5WOFn4FKM/4PN1TtFukZPSUkI
>> =/4tC
>> -----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
>>
>
> 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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
Christopher,

Well, I'm not a web expert, so if there's a better way (redirect) I'm  
all ears.

 From what I can find by googling, redirects have a slew of issues of  
their own. But I'm a newbie at this, so I might be misunderstanding.

How would I do a redirect in Tomcat for my stated issue, keeping in  
mind that doing so is case-by-case, not a nice regexp pattern.

Lloyd

On Apr 25, 2008, at 1:05 PM, Christopher Schultz wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lloyd,
>
> DIGLLOYD INC wrote:
> | 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" />
>
> This is a very weird way to do things. You should either generate
> content /or/ forward. Why are you doing both?
>
> Instead of using a forward, why not do a redirect? That way, the new
> request has the correct URL and your relative paths should be correct.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkgSOW4ACgkQ9CaO5/Lv0PCZtgCgwMQ2Nq53WFJV1qA2UtOVT62P
> aroAoLf5WOFn4FKM/4PN1TtFukZPSUkI
> =/4tC
> -----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
>

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


Re: simple JSP redirect to another page -- how to deal with relative URLs

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

Lloyd,

DIGLLOYD INC wrote:
| 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" />

This is a very weird way to do things. You should either generate
content /or/ forward. Why are you doing both?

Instead of using a forward, why not do a redirect? That way, the new
request has the correct URL and your relative paths should be correct.

- -chris

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

iEYEARECAAYFAkgSOW4ACgkQ9CaO5/Lv0PCZtgCgwMQ2Nq53WFJV1qA2UtOVT62P
aroAoLf5WOFn4FKM/4PN1TtFukZPSUkI
=/4tC
-----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: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
Thanks for everyone's help on this and my related message.

I found that using org.tuckey.web.filters.urlrewrite.UrlRewriteFilter  
works well: http://tuckey.org/urlrewrite/

With entries like:

     <rule>
         <from>/diglloyd/free/CardReaders/CardReaders.html</from>
         <to type="redirect">/diglloyd/free/CardReaders/</to>
     </rule>

(I'm not sure if I should stick "index.html" in the "to" URL)

Lloyd


On Apr 27, 2008, at 1:13 PM, DIGLLOYD INC wrote:

> David,
>
> I want to redirect perhaps a dozen links in directories that have a  
> main page accessed something like:
> /stuff/start-page.html
>
> In thinking about this, maybe my best solution is to rename the main  
> page to "index.html" for simplicity and use the org.tuckey.web.filters.urlrewrite.UrlRewriteFilter 
>  with basic patterns.
>
> Lloyd
>
> On Apr 25, 2008, at 1:38 PM, David Fisher wrote:
>
>> Seconded.
>>
>> DIGLLOYD said the following:
>>
>>> From what I can find by googling, redirects have a slew of issues  
>>> of their own. But I'm a newbie at this, so I might be  
>>> misunderstanding.
>>
>> The only trouble I've had with redirects is when you redirect to a  
>> page which redirects to a page which redirects to a page. Browsers  
>> consider more than a few redirects in a row to be a bad thing and  
>> they stop. My experience taught me (about 7 years ago) that more  
>> then 2 was pushing things.
>>
>> DIGLLOYD are only replacing a single generation of files, as you do  
>> this "relinking" how many links do you want to "forward" or  
>> "redirect"?
>>
>> Regards,
>> Dave
>>
>> On Apr 25, 2008, at 3:27 PM, David Smith wrote:
>>
>>> Never mind .. I saw your other responses and the best solution is  
>>> the redirect option.  After following the redirect, the browser  
>>> will have the correct URL for calculating the full url of each of  
>>> the page's resources.
>>>
>>> --David
>>>
>>> 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
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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
>

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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by DIGLLOYD INC <di...@diglloyd.com>.
David,

I want to redirect perhaps a dozen links in directories that have a  
main page accessed something like:
/stuff/start-page.html

In thinking about this, maybe my best solution is to rename the main  
page to "index.html" for simplicity and use the org.tuckey.web.filters.urlrewrite.UrlRewriteFilter 
  with basic patterns.

Lloyd

On Apr 25, 2008, at 1:38 PM, David Fisher wrote:

> Seconded.
>
> DIGLLOYD said the following:
>
>> From what I can find by googling, redirects have a slew of issues  
>> of their own. But I'm a newbie at this, so I might be  
>> misunderstanding.
>
> The only trouble I've had with redirects is when you redirect to a  
> page which redirects to a page which redirects to a page. Browsers  
> consider more than a few redirects in a row to be a bad thing and  
> they stop. My experience taught me (about 7 years ago) that more  
> then 2 was pushing things.
>
> DIGLLOYD are only replacing a single generation of files, as you do  
> this "relinking" how many links do you want to "forward" or  
> "redirect"?
>
> Regards,
> Dave
>
> On Apr 25, 2008, at 3:27 PM, David Smith wrote:
>
>> Never mind .. I saw your other responses and the best solution is  
>> the redirect option.  After following the redirect, the browser  
>> will have the correct URL for calculating the full url of each of  
>> the page's resources.
>>
>> --David
>>
>> 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
>>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: simple JSP redirect to another page -- how to deal with relative URLs

Posted by David Fisher <df...@jmlafferty.com>.
Seconded.

DIGLLOYD said the following:

> From what I can find by googling, redirects have a slew of issues of  
> their own. But I'm a newbie at this, so I might be misunderstanding.

The only trouble I've had with redirects is when you redirect to a  
page which redirects to a page which redirects to a page. Browsers  
consider more than a few redirects in a row to be a bad thing and they  
stop. My experience taught me (about 7 years ago) that more then 2 was  
pushing things.

DIGLLOYD are only replacing a single generation of files, as you do  
this "relinking" how many links do you want to "forward" or "redirect"?

Regards,
Dave

On Apr 25, 2008, at 3:27 PM, David Smith wrote:

> Never mind .. I saw your other responses and the best solution is  
> the redirect option.  After following the redirect, the browser will  
> have the correct URL for calculating the full url of each of the  
> page's resources.
>
> --David
>
> 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
>>
>
>
> ---------------------------------------------------------------------
> 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: simple JSP redirect to another page -- how to deal with relative URLs

Posted by David Smith <dn...@cornell.edu>.
Never mind .. I saw your other responses and the best solution is the 
redirect option.  After following the redirect, the browser will have 
the correct URL for calculating the full url of each of the page's 
resources.

--David

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
>


---------------------------------------------------------------------
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: simple JSP redirect to another page -- how to deal with relative URLs

Posted by David Smith <dn...@cornell.edu>.
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