Mantis - Resin
Viewing Issue Advanced Details
2379 minor always 01-29-08 07:05 02-13-08 13:38
wimsie  
ferg  
normal  
closed 3.1.3  
fixed  
none    
none 3.1.5  
0002379: using JSTL core redirect tag causes malformed URIs when context attribute is set to "/"
I have the page Resin.html within I want to redirect to another page with
the use of JTSL. But when trying to use JSTLs core redirect-Tag, i always
run into problems.

Here is the source of this page.

Resin.html

<!DOCTYPE html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ taglib prefix="custom" uri="http://example.org/jstl/custom" [^] %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" [^] %>
<html>
<head>
    <title>Resin Test Page</title>
</head>
<body>
    <c:set var="redirURL"><custom:URL jspPage="MyPage"/></c:set>
    <c:redirect url="${redirURL}" context="/">
</body>
</html>

<custom:URL> gives me the absolute path of 'MyPage' within the context of
the webapp as '/context/MyPage.html', where '/context' is configured as
webapp id in resin.conf

resin.conf

<web-app id='/context' root-directory='/home/resin/webapp' work-dir='/home/resin/work'>
...
</web-app>

Without using the context param of c:redirect the page will be redirected to the address
'/context/context/MyPage.html'.

Using a blank context param, i get the following error.

javax.servlet.jsp.JspException: URL context '' must start with '/'

So I thought using context="/", as shown in Resin.html, will bring it to me. But now the
redirect is done to '//context/MyPage.html'.

Is it possible to fix this double slash within com/caucho/jstl/rt/CoreUrlTag.java??

The method normalizeURL at line 157ff only does
value.append(context);
value.append(url);

Wouldn't it be better to check for duplicate slashes??
if (context.equals("/")) {
    value.append(url);
} else {
    value.append(context + url);
}

Notes
(0002768)
ferg   
02-13-08 13:38   
jsp/1ck5