Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6111

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 7.2.0
    • 7.3.0, 8.0.0-M1, 6.23.0
    • wicket
    • None
    • Windows 8.1 x86-64, Tomcat 7.0.67

    Description

      Wicket seems to produce an empty redirect if a user already opened the home page of an app and gets redirected to the same page by e.g. clicking a link containing the following line:

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

      In my case the purpose of the link is to sign out and redirect all users to a well known page afterwards. Involved URLs:

      http://localhost:8080/org.example.frontend/?0
      http://localhost:8080/org.example.frontend/?0-1.ILinkListener-home.signOut
      

      In this case Wicket creates an empty target URL for a redirect and sends that to my Tomcat 7, which seem to just forward it to the browser, which does nothing. The result is that the user sits on a white page and needs to refresh manually using e.g. F5. In contrast with a qucikstart containing and embedded Jetty, Wicket generates the exact same empty target URL but Jetty seem to resolve it internally to a absolut URL and therefore the requests succeeds now.

      Example from the browser using Tomcat 7:

      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
      

      And from Jetty:

      Request URL:http://localhost:8080/org.example.frontend/?0-1.ILinkListener-home.signOut
      Request Method:GET
      Status Code:302 Found
      Remote Address:[::1]:8080
      Response Headers
      view source
      Cache-Control:no-cache, no-store
      Content-Length:0
      Date:Mon, 07 Mar 2016 15:12:40 GMT
      Expires:Thu, 01 Jan 1970 00:00:00 GMT
      Location:http://localhost:8080/org.example.frontend/
      Pragma:no-cache
      Server:Jetty(9.2.13.v20150730)
      

      Debugging lead to org.apache.wicket.protocol.http.servlet.ServletWebResponse#encodeRedirectURL and #sendRedirect:

      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.

      Attachments

        1. empty_redirect.zip
          46 kB
          Thorsten Schöning

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              tschoening Thorsten Schöning
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: