struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Cook" <jimc...@iname.com>
Subject RE: The use of '..' in relative path includes in JSPs
Date Mon, 12 Mar 2001 03:36:57 GMT
Very cool. Thanks for that info.

I thought I saw an option at one time to force URL encoding in Struts, even
if the browser supports cookies. Is this true, and will the page attribute
also URL encode?

thank you,
jim

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Sunday, March 11, 2001 10:15 PM
> To: struts-user@jakarta.apache.org
> Subject: RE: The use of '..' in relative path includes in JSPs
>
>
>
>
> On Sun, 11 Mar 2001, James Cook wrote:
>
> > Craig,
> >
> > Forwards and redirects not withstanding, is it a fair statement
> to conclude
> > that all links (hrefs, image srcs, etc.) in a web application must be
> > rendered in a relative manner?
> >
>
> Unfortunately, we could not make such a rule even if we wanted to.
>
> > There isn't any talk of making <img src="/images/a.gif"> relative to a
> > context is there?
> >
>
> No, but it's not because this would not be desireable for servlet apps
> :-).
>
> The problem is that paths in an <img> or <a> tag are interpreted by the
> *browser*, not by the server.  The path "/images/a.gif" is going to be
> interpreted as being relative to the document root of the server, not the
> context root of the application.  Browsers have no clue what a web
> application is.
>
> Struts tries to help you deal with this unpleasantness by including the
> "page" attribute on the <html:link> and <html:image> tags, which both
> accept a context relative path.  They both convert this path to be
> relative to the server's document root before sending to the browser, so
> you can at least pretend your links are all context-relative.  So, you can
> safely use:
>
> 	<html:image page="/images/a.gif"/>
>
> and it will get converted to (assuming "/myapp" is your context path):
>
> 	<img src="/myapp/images/a.gif">
>
> which will work as you expect.
>
> > jim
> >
>
> Craig
>


Mime
View raw message