You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2016/03/06 20:39:00 UTC

Empty redirect on redirect to home page if home page already shown

Hi all,

I have a web app with an empty fallback home page which is of no use
most of the times, only if the wrong people login to my app they get
this home page presented. Every other user is redirected to another
page with some meaningful content. If all users logout, they normally
get redirected to the home page, which needs authentication, so users
get redirected to the sign in page and afterwards to some other page
depending on which user logged in. In some rare cases this is the
homepage again.

The problem no is for those rare users sitting at the home page: If
those logout they should get redirected to the home page and
afterwards to the sign in page again like all other users. But Wicket
renders some empty redirect, I guess because the users are already at
the home page, and the browser does nothing, especially it doesn't
send another request. If I issue the request manually in the browser I
get redirected to the sign in page properly.

The following are the URLs involved:

> http://localhost:8081/org.example.frontend/?3
> http://localhost:8081/org.example.frontend/?3-1.ILinkListener-html-body-pnNav-home.signOut

The first one is after successful authentication and presents the
content of the home page, the second one is the sign out url and stays
in the browser with empty content, because of the empty "Location"
header in the generated 302 response.

> Request URL:http://localhost:8081/org.example.frontend/?3-1.ILinkListener-html-body-pnNav-home.signOut
> Request Method:GET
> Status Code:302 Found
> Remote Address:127.0.0.1:8081
> Cache-Control:no-cache, no-store
> Content-Length:0
> Date:Sun, 06 Mar 2016 19:34:40 GMT
> Expires:Thu, 01 Jan 1970 00:00:00 GMT
> Location:
> Pragma:no-cache
> Server:Apache-Coyote/1.1
> Set-Cookie:JSESSIONID=[...]; Path=/org.example.frontend/; HttpOnly

My sign out logic ends with the following, after making some custom
things:

> RequestCycle.get().setResponsePage(Application.get().getHomePage(), params);

Any ideas of what I'm doing wrong and what needs to be done to get my
behavior? I want to redirect always to getHomePage(), even if it's
already shown and Wicket tries to do it, it just renders an incomplete
URL.

Thanks for your help!

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Empty redirect on redirect to home page if home page already shown

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Martin Grigorov,
am Montag, 7. März 2016 um 11:55 schrieben Sie:

> Please file a ticket with this information and the quickstart.

https://issues.apache.org/jira/browse/WICKET-6111

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Empty redirect on redirect to home page if home page already shown

Posted by Martin Grigorov <mg...@apache.org>.
Please file a ticket with this information and the quickstart.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Mar 7, 2016 at 11:38 AM, Thorsten Schöning <ts...@am-soft.de>
wrote:

> Guten Tag Martin Grigorov,
> am Montag, 7. März 2016 um 10:06 schrieben Sie:
>
> > Try with latest Tomcat release. There were some changes in this area
> > recently.
>
> I'm already using 7.0.67, the most current is only 7.0.68, but our
> production server is an even older version maintained by apt, so I
> would need a workaround in my app anyways.
>
> >
> org.apache.wicket.protocol.http.servlet.ServletWebResponse#encodeRedirectURL
>
> That's what I needed to find, thanks! This function behaves (nearly)
> the same for my URLs, the only difference is the following line:
>
> > Url originalUrl = Url.parse(url);
>
> In my Tomcat I get a completely empty object, NOT null though, in the
> quickstart with Jetty I get an object containing ".". But in the end
> that doesn't seem to make any difference, both requests go through the
> following:
>
> > if (fullUrl.equals(encodedFullUrl))
> > {
> >         // no encoding happened so just reuse the original url
> >         encodedUrl = url.toString();
> > }
>
> encodedUrl is "./" using Tomcat and Jetty as well, while "fullUrl"
> contains an absolute URL in both cases:
>
> > http://localhost:8080/org.example.frontend/
>
> "./" is returned to ServletWebResponse.sendRedirect and runs into the
> following:
>
> > if (url.startsWith("./"))
> > {
> >         /*
> >          * WICKET-4260 Tomcat does not canonalize urls, which leads to
> problems with IE
> >          * when url is relative and starts with a dot
> >          */
> >         url = url.substring(2);
> > }
>
> And that empties my URL and forwards it to the servlet container,
> where Jetty instead of Tomcat seems to provide some magic to respond
> with an absolute URL in the end. But my debugger says that in both
> cases
>
> > httpServletResponse.sendRedirect(url);
>
> gets called with an empty string!
>
> > But we'll let ServletWebResponse remove a leading "./" before passing
> the url to HttpServletRequest#sendRedirect().
> > This does no harm and as you stated is essential as a workaround for the
> Tomcat/IE combination.
>
>
> https://issues.apache.org/jira/browse/WICKET-4260?focusedCommentId=13247750&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13247750
>
> It does harm in my case... ;-)
>
> So, any ideas on how I can work around this and what should be the
> correct behavior? Is having "./" already a problem or only to remove
> it when there's nothing left anymore?
>
> I don't see any callback or listener or such where I could influence
> that behavior...
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Empty redirect on redirect to home page if home page already shown

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Martin Grigorov,
am Montag, 7. März 2016 um 10:06 schrieben Sie:

> Try with latest Tomcat release. There were some changes in this area
> recently.

I'm already using 7.0.67, the most current is only 7.0.68, but our
production server is an even older version maintained by apt, so I
would need a workaround in my app anyways.

> org.apache.wicket.protocol.http.servlet.ServletWebResponse#encodeRedirectURL

That's what I needed to find, thanks! This function behaves (nearly)
the same for my URLs, the only difference is the following line:

> Url originalUrl = Url.parse(url);

In my Tomcat I get a completely empty object, NOT null though, in the
quickstart with Jetty I get an object containing ".". But in the end
that doesn't seem to make any difference, both requests go through the
following:

> if (fullUrl.equals(encodedFullUrl))
> {
>         // no encoding happened so just reuse the original url
>         encodedUrl = url.toString();
> }

encodedUrl is "./" using Tomcat and Jetty as well, while "fullUrl"
contains an absolute URL in both cases:

> http://localhost:8080/org.example.frontend/

"./" is returned to ServletWebResponse.sendRedirect and runs into the
following:

> if (url.startsWith("./"))
> {
>         /*
>          * WICKET-4260 Tomcat does not canonalize urls, which leads to problems with IE
>          * when url is relative and starts with a dot
>          */
>         url = url.substring(2);
> }

And that empties my URL and forwards it to the servlet container,
where Jetty instead of Tomcat seems to provide some magic to respond
with an absolute URL in the end. But my debugger says that in both
cases

> httpServletResponse.sendRedirect(url);

gets called with an empty string!

> But we'll let ServletWebResponse remove a leading "./" before passing the url to HttpServletRequest#sendRedirect().
> This does no harm and as you stated is essential as a workaround for the Tomcat/IE combination.

https://issues.apache.org/jira/browse/WICKET-4260?focusedCommentId=13247750&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13247750

It does harm in my case... ;-)

So, any ideas on how I can work around this and what should be the
correct behavior? Is having "./" already a problem or only to remove
it when there's nothing left anymore?

I don't see any callback or listener or such where I could influence
that behavior...

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Empty redirect on redirect to home page if home page already shown

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Mon, Mar 7, 2016 at 9:59 AM, Thorsten Schöning <ts...@am-soft.de>
wrote:

> Guten Tag Sven Meier,
> am Sonntag, 6. März 2016 um 22:08 schrieben Sie:
>
> > I wouldn't expect Wicket to generate an empty location header. Can you
> > reproduce this problem in a Wicket quickstart?
>
> You are right, I forgot to mention it: During debugging I already
> noticed that Wicket is in fact rendering "./" instead of an empty
> string using UrlRenderer.renderRelativeUrl, but I thought this might
> get changed later to an empty string for some reason.
>
> I created a quickstart and "sadly" this worked as expected, the client
> is getting the following header:
>
> > Location:http://localhost:8081/org.example.frontend/
>
> But in the debugger the processing looks identical to my problem, the
> quickstart renders "./" as well. The only difference seems to be that
> in my case the browser isn't getting a properly resolved URL anymore,
> but and empty string or such, while that's not the case with the
> quickstart.
>
> My servlet container with the problem is Tomcat 7, while the
>

Try with latest Tomcat release. There were some changes in this area
recently.

You can also put a breakpoint
at org.apache.wicket.protocol.http.servlet.ServletWebResponse#encodeRedirectURL
and see what the web containers return
from javax.servlet.http.HttpServletResponse#encodeRedirectURL()


> quickstart uses embedded Jetty? I guess I'll need to focus on that for
> now and find a difference.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Empty redirect on redirect to home page if home page already shown

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Sven Meier,
am Sonntag, 6. März 2016 um 22:08 schrieben Sie:

> I wouldn't expect Wicket to generate an empty location header. Can you
> reproduce this problem in a Wicket quickstart?

You are right, I forgot to mention it: During debugging I already
noticed that Wicket is in fact rendering "./" instead of an empty
string using UrlRenderer.renderRelativeUrl, but I thought this might
get changed later to an empty string for some reason.

I created a quickstart and "sadly" this worked as expected, the client
is getting the following header:

> Location:http://localhost:8081/org.example.frontend/

But in the debugger the processing looks identical to my problem, the
quickstart renders "./" as well. The only difference seems to be that
in my case the browser isn't getting a properly resolved URL anymore,
but and empty string or such, while that's not the case with the
quickstart.

My servlet container with the problem is Tomcat 7, while the
quickstart uses embedded Jetty? I guess I'll need to focus on that for
now and find a difference.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Empty redirect on redirect to home page if home page already shown

Posted by Sven Meier <sv...@meiers.net>.
Hi Thorsten,

 > Location:

I wouldn't expect Wicket to generate an empty location header. Can you 
reproduce this problem in a Wicket quickstart?

Regards
Sven


On 06.03.2016 20:39, Thorsten Schöning wrote:
> Hi all,
>
> I have a web app with an empty fallback home page which is of no use
> most of the times, only if the wrong people login to my app they get
> this home page presented. Every other user is redirected to another
> page with some meaningful content. If all users logout, they normally
> get redirected to the home page, which needs authentication, so users
> get redirected to the sign in page and afterwards to some other page
> depending on which user logged in. In some rare cases this is the
> homepage again.
>
> The problem no is for those rare users sitting at the home page: If
> those logout they should get redirected to the home page and
> afterwards to the sign in page again like all other users. But Wicket
> renders some empty redirect, I guess because the users are already at
> the home page, and the browser does nothing, especially it doesn't
> send another request. If I issue the request manually in the browser I
> get redirected to the sign in page properly.
>
> The following are the URLs involved:
>
>> http://localhost:8081/org.example.frontend/?3
>> http://localhost:8081/org.example.frontend/?3-1.ILinkListener-html-body-pnNav-home.signOut
> The first one is after successful authentication and presents the
> content of the home page, the second one is the sign out url and stays
> in the browser with empty content, because of the empty "Location"
> header in the generated 302 response.
>
>> Request URL:http://localhost:8081/org.example.frontend/?3-1.ILinkListener-html-body-pnNav-home.signOut
>> Request Method:GET
>> Status Code:302 Found
>> Remote Address:127.0.0.1:8081
>> Cache-Control:no-cache, no-store
>> Content-Length:0
>> Date:Sun, 06 Mar 2016 19:34:40 GMT
>> Expires:Thu, 01 Jan 1970 00:00:00 GMT
>> Location:
>> Pragma:no-cache
>> Server:Apache-Coyote/1.1
>> Set-Cookie:JSESSIONID=[...]; Path=/org.example.frontend/; HttpOnly
> My sign out logic ends with the following, after making some custom
> things:
>
>> RequestCycle.get().setResponsePage(Application.get().getHomePage(), params);
> Any ideas of what I'm doing wrong and what needs to be done to get my
> behavior? I want to redirect always to getHomePage(), even if it's
> already shown and Wicket tries to do it, it just renders an incomplete
> URL.
>
> Thanks for your help!
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org