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

ServletWebRequest#getURL does not return relative URLs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.4
    • 1.3.8
    • wicket
    • None

    Description

      The description of Request#getURL() is:
      /**

      • Retrieves the relative URL of this request for local use. This is relative to the context
      • root.
      • @return The relative request URL for local use
        */

      But ServletWebRequest#getURL uses HttpServletRequest#getServletPath which returns the path to the context of the servlet (so if the servlet is under 'foo' (so http://localhost:8080/foo activates it)), so the path is not relative for local use.

      In my specific case, this fails to redirect properly after login:
      When using authentication, PageMap#setUpRedirect is used to store the intercepted URL and PageMpa#continueToOriginalDestination is used to redirect to it after a successful login.

      The issue is that setUpRedirect uses cycle.getRequest().getURL() so part of the url contains the context path. Then continueToOriginalDestination uses RedirectRequestTarget which uses 'response.redirect(RequestCycle.get()
      .getRequest()
      .getRelativePathPrefixToContextRoot() +
      redirectUrl.substring(1)'

      so the call response.redirect is made with a relative path form, which contains the context. the web server adds the context path again before sending to the client to make the path absolute, which results in an illegal path.

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            ittayd Ittay Dror
            Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: