Hi Martin,
Sorry for the confusion I meant that i've seen
org.apache.wicket.util.string.Strings.stripJSessionId(uri) being called for
ResourceReferences to Javascript and Css.
I'm using wicket 1.5.1 and tomcat 6.0.33.
You're right - I've traced from
org.apache.wicket.protocol.http.servlet.ServletWebResponse.sendRedirect(String)
and it seems like there is a problem with "?1" and
org.apache.catalina.connector.toEncoded(String url, String sessionId).
In toEncoded(String url, String sessionId) when url = "?1" it seems that
the parameter is NOT appended since variable path is of length zero and if(
sb.length() > 0 ) is false. (in order to see a value of "?1" i set a
breakpoint in ServletWebResponse.sendRedirect followed by a breakpoint in
toEncoded)
Since it seems to work for the rest of the world I guess I'm doing
something wrong ...
protected String toEncoded(String url, String sessionId) {
if ((url == null) || (sessionId == null))
return (url);
String path = url;
String query = "";
String anchor = "";
int question = url.indexOf('?');
if (question >= 0) {
path = url.substring(0, question);
query = url.substring(question);
}
int pound = path.indexOf('#');
if (pound >= 0) {
anchor = path.substring(pound);
path = path.substring(0, pound);
}
StringBuffer sb = new StringBuffer(path);
if( sb.length() > 0 ) { // jsessionid can't be first.
sb.append(";");
sb.append(Globals.SESSION_PARAMETER_NAME);
sb.append("=");
sb.append(sessionId);
}
sb.append(anchor);
sb.append(query);
return (sb.toString());
}
Thanks
Thomas
On Wed, Nov 16, 2011 at 1:39 PM, Martin Grigorov <[email protected]>wrote:
> Hi,
>
> On Wed, Nov 16, 2011 at 2:29 PM, thomas willomitzer
> <[email protected]> wrote:
> > Dear all,
> >
> > I've spent quite a bit of time tracking down a problem I'm having using
> > wicket and stateful pages.
> > I've enabled the jsessionid url rewriting in tomcat (by simply using the
> > default settings) but I get a redirect url without the jsessionid.
> >
> > I've traced into tomcat's Response.encodeUrl and saw that the jsessionid
> is
> > in fact appended (but later removed for in page references by wicket -
> > that's fine).
>
> What do you mean by that ? Where Wicket removes the jsessionid from the
> url ?
> Before issuing a redirect Wicket calls
> javax.servlet.http.HttpServletResponse.encodeRedirectURL(String) which
> is responsible to put jsessionid if cookies are disabled.
> See
> org.apache.wicket.protocol.http.servlet.ServletWebResponse.sendRedirect(String)
>
> The application I work on works without cookies and all if fine. (Wicket
> 1.5.3)
>
> >
> > What am I doing wrong and am I right in the assumption that wicket should
> > work without cookies?
> >
> > When using curl I first get a redirect to ?1, then to /. and then a 404
> >
> > $ curl -v http://localhost
> > * About to connect() to localhost port 80 (#0)
> > * Trying 127.0.0.1... connected
> > * Connected to localhost (127.0.0.1) port 80 (#0)
> >> GET / HTTP/1.1
> >> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k
> > zlib/1.2.3
> >> Host: localhost
> >> Accept: */*
> >>
> > < HTTP/1.1 302 Moved Temporarily
> > < Server: Apache-Coyote/1.1
> > < Set-Cookie: JSESSIONID=
> > CA5649F5EA37AC7CDB2D5E06170923A1; Path=/
> > < Date: Wed, 16 Nov 2011 12:16:15 GMT
> > < Expires: Thu, 01 Jan 1970 00:00:00 GMT
> > < Pragma: no-cache
> > < Cache-Control: no-cache, no-store
> > < Location: http://localhost/?1
> > < Content-Length: 0
> > <
> > * Connection #0 to host localhost left intact
> > * Closing connection #0
> >
> > thomas@willo ~
> > $ curl -v http://localhost?1 <http://localhost/?1>
> > * About to connect() to localhost port 80 (#0)
> > * Trying 127.0.0.1... connected
> > * Connected to localhost (127.0.0.1) port 80 (#0)
> >> GET /?1 HTTP/1.1
> >> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k
> > zlib/1.2.3
> >> Host: localhost
> >> Accept: */*
> >>
> > < HTTP/1.1 302 Moved Temporarily
> > < Server: Apache-Coyote/1.1
> > < Date: Wed, 16 Nov 2011 12:16:21 GMT
> > < Expires: Thu, 01 Jan 1970 00:00:00 GMT
> > < Pragma: no-cache
> > < Cache-Control: no-cache, no-store
> > < Location: http://localhost/.
> > < Content-Length: 0
> > <
> > * Connection #0 to host localhost left intact
> > * Closing connection #0
> >
> > thomas@willo ~
> > $ curl -v http://localhost/.
> > * About to connect() to localhost port 80 (#0)
> > * Trying 127.0.0.1... connected
> > * Connected to localhost (127.0.0.1) port 80 (#0)
> >> GET /. HTTP/1.1
> >> User-Agent: curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8k
> > zlib/1.2.3
> >> Host: localhost
> >> Accept: */*
> >>
> > < HTTP/1.1 404 Not Found
> > < Server: Apache-Coyote/1.1
> > < Content-Type: text/html;charset=utf-8
> > < Content-Length: 958
> > < Date: Wed, 16 Nov 2011 12:16:24 GMT
> > <
> > <html><head><title>Apache Tomcat/6.0.33 - Error
> report</title><style><!--H1
> >
> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:
> > 22px;} H2
> >
> {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
> > H3 {font-family:Tahoma,Arial,sans-serif;color:white;backgro
> > und-color:#525D76;font-size:14px;} BODY
> >
> {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B
> > {font-family:Tahoma,Arial,sans-serif;color:w
> > hite;background-color:#525D76;} P
> >
> {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
> > {color : black;}A.name {color : black;}HR
> > {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 -
> /.</h1><HR
> > size="1" noshade="noshade"><p><b>type</b> Status
> > report</p><p><b>message</b> <u>/.</
> > u></p><p><b>description</b> <u>The requested resource (/.) is not
> > available.</u></p><HR size="1" noshade="noshade"><h3>Apache
> > Tomcat/6.0.33</h3></body></html>*
> > Connection #0 to host localhost left intact
> > * Closing connection #0
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>