You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthias Kerkhoff <ma...@BESToffers.de> on 2000/11/20 23:37:13 UTC

struts tags with URL#anchor + query strings -> no-go

Hi'ya - I've just discovered a widespread problem in most
struts tags. Nearly all tags will fail to handle anchors
(that's a kind of intra-document reference) properly.
Anchors have to be the last part of an URI/URL - even
if a query string is present. Because struts, as most
other taglibs appends the query parameter always at the
end of a given URL

A fictive example:
Appending variable a and b with the values 1 and 2 as
query string to www.myserver.com/myapp.jsp#footer (one
could use the link tag for this) will result in
www.myserver.com/myapp.jsp#footer?a=1&c=2, but the correct
result should be www.myserver.com/myapp.jsp?a=1&c=2#footer.
I could also throw in the path-info, but this is less
often used and would complicate things even more.

Using WLS 5.1, there is an additional side-effect of the
way struts (doesn't) handle anchors: The session will
be lost, if url-rewriting is used and the URL in question
contains an anchor (BTW: Weblogic has the same "bug", it
also appends the URL always at the end, ignoring anchors
completly)

-- 
Matthias                          mailto:make@BESToffers.de



Re[2]: struts tags with URL#anchor + query strings -> no-go

Posted by Matthias Kerkhoff <ma...@BESToffers.de>.
> The servlet 2.2 spec requires that the session id be passed as a *path*
> parameter (separated from the base URI by a semicolon), not a *query*
> parameter.  Was it WebLogic or one of the other servers that was also not doing
> this right.

Yes I know. I had some weeks ago a lengthy discussion with BEA
about how they've implemented url-rewriting. At that time, they
even couldn't tell me if it will go into 6.0 - but this may
have changed in the meantime.

> At any rate, Struts will rely on the servlet container's response.encodeURL()
> method to do the URL rewriting, so there's nothing Struts can do about a
> container that gets this wrong.

My mail was intended for people that may run into the same problem sometimes
in the future, not a call for action ;) Beside that, it's not that difficult
to write a function that moves an #anchor to where it belongs.

-- 
Matthias                        (mailto:make@BESToffers.de)

BTW.: Whats the correct result of encodeURL("#") (with url-rewriting
turned on) ?



Re: struts tags with URL#anchor + query strings -> no-go

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Matthias Kerkhoff wrote:

> Hi'ya - I've just discovered a widespread problem in most
> struts tags. Nearly all tags will fail to handle anchors
> (that's a kind of intra-document reference) properly.
> Anchors have to be the last part of an URI/URL - even
> if a query string is present. Because struts, as most
> other taglibs appends the query parameter always at the
> end of a given URL
>
> A fictive example:
> Appending variable a and b with the values 1 and 2 as
> query string to www.myserver.com/myapp.jsp#footer (one
> could use the link tag for this) will result in
> www.myserver.com/myapp.jsp#footer?a=1&c=2, but the correct
> result should be www.myserver.com/myapp.jsp?a=1&c=2#footer.
> I could also throw in the path-info, but this is less
> often used and would complicate things even more.
>

Yep, that's a bug when you use the link tag's ability to create query parameters
dynamically.  Yuck.

>
> Using WLS 5.1, there is an additional side-effect of the
> way struts (doesn't) handle anchors: The session will
> be lost, if url-rewriting is used and the URL in question
> contains an anchor (BTW: Weblogic has the same "bug", it
> also appends the URL always at the end, ignoring anchors
> completly)
>

The servlet 2.2 spec requires that the session id be passed as a *path*
parameter (separated from the base URI by a semicolon), not a *query*
parameter.  Was it WebLogic or one of the other servers that was also not doing
this right.

At any rate, Struts will rely on the servlet container's response.encodeURL()
method to do the URL rewriting, so there's nothing Struts can do about a
container that gets this wrong.

>
> --
> Matthias                          mailto:make@BESToffers.de

Craig