On Tue, 9 Jul 2002, Struts Newsgroup wrote:

> Date: Tue, 9 Jul 2002 14:40:01 -0700
> From: Struts Newsgroup <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: html:base misunderstood, broken, or misleading?
>
> Subject: html:base misunderstood, broken, or misleading?
> From: Eric Rizzo <[EMAIL PROTECTED]>
>  ===
> I've got a problem using Struts under Jetty that I think is related to
> the <html:base> tag.
> The comments for this tag read:
> "Renders an HTML <base> element with an href attribute pointing to the
> absolute location of the enclosing JSP page. [snip]
> This tag is useful because it allows you to use relative URL references
> in the page that are calculated based on the URL of the page itself,
> rather than the URL to which the most recent submit took place (which is
> where the browser would normally resolve relative references against)."
>
> But the <base> html element it generates does not point to the JSP page.
>   It generates something like
> <base href="http://localhost:8080/appName/action.do";>
>
> which does not point to the JSP location as the docs indicate.  Tomcat
> seems to deal with this fine anyway - I can use relative paths to other
> resources (CSS, images, other JSPs) or use the Struts custom tags to
> generate full "proper" paths to them.
> But when the app is run under Jetty, the relative references stop
> working.  For example, something like this fails when /images is a
> sibling of /jsp:
>      <img src="../images/foo.gif">
>
> The problem seems to be that the request for foo.gif is sent back with a
> URL of "/images/foo.gif" although it should be
> "/appName/jsp/../images/foo.gif" or "/appName/images/foo.gif"
>
> My questions are:
> 1) Why does the <html:base> tag not work according to what is documented
> and expected?
> 2) Why would Tomcat not care but Jetty does?
>

This sounds like a bug in Jetty.

The Struts code that computes the URL simply calls
request.getRequestURI().  After a forward, this is supposed to give you
the request URI of the resource you forwarded to (i.e. the JSP page).  It
looks like Jetty is still returning you the URI of the original request,
which is a violation of the servlet spec -- for Servlet 2.3, it's in
Section 8.4:

    "The path elements of the request object exposed to
    the target servlet must reflect the path used to obtain
    the RequestDispatcher."

You should forward this note to the Jetty developers -- they are very
responsive, especially on spec related issues.

>
> TIA,
>       Eric

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to