3

Using Websphere Application Server + Wicket 1.6 I am having some issues with my mounted URLs.

When I invoke an url akin to: localhost:9080/danesCooking/pies/meat I see the following in the Chrome network tab:

localhost:9080/danesCooking/pies/meat status code 302
localhost:9080/danesCooking/meat?2 status code 404

So it seems the /pies/ portion gets lost. This behaviour does not occur when I deploy my application to Tomcat\JBoss\... .

Possibly relevant, pies itself is not a mounted page.

I've already looked through some of the wicket issues\forums and it seems most issues seem to be either resolved\conflicting answers\have to do with relative urls (fixed in 1.5.x).

Has anyone experienced this issue and still recalls how to resolve this?

Used WAS *Versions: 7 and 8.5* liberty.

Laura
  • 13
  • 6
Kate Danes
  • 63
  • 6

2 Answers2

6

This issue is actually outlined here; https://issues.apache.org/jira/browse/WICKET-3258

My resolution to the issue in Wicket 6.9.1 was;

public class MyApplication extends WebApplication {

    @Override
    public Class<? extends WebPage> getHomePage() {
        return MyHomePage.class;
    }

    /* *********************************************** */
    // Resolve Websphere Relative URL "sendRedirect" Bug

    @Override
    protected WebResponse newWebResponse(WebRequest webRequest, HttpServletResponse httpServletResponse) {
        return new FixedServletWebResponse((ServletWebRequest) webRequest, httpServletResponse);
    }

    /**
     * Websphere incorrectly handles relative redirect pages when "HttpServletResponse.sendRedirect(url)" is called.
     * 
     * This small fix ensures that Websphere is only ever provided with absolute URLs so that this issue never occurs.
     */
    private static class FixedServletWebResponse extends ServletWebResponse {
        private final ServletWebRequest webRequest;

        protected FixedServletWebResponse(ServletWebRequest webRequest, HttpServletResponse httpServletResponse) {
            super(webRequest, httpServletResponse);
            this.webRequest = webRequest;
        }

        @Override
        public String encodeRedirectURL(CharSequence url) {
            Url relativeUrl = Url.parse(url);
            return new UrlRenderer(webRequest).renderFullUrl(relativeUrl);
        }
    }

    /* *********************************************** */
}
Glenn
  • 61
  • 1
  • 2
0

You can also solve that using anonymous class as described in the Configuring and Deploying Open Source with WebSphere Application Server Liberty Profile chapter 5.2.4. (Tested with WLP 8.5.5.3 and Wicket 6.8.0)

Override the following method in your WebApplication class:

    @Override
    protected WebResponse newWebResponse(final WebRequest webRequest, final
    HttpServletResponse httpServletResponse)
    {
        return new ServletWebResponse((ServletWebRequest) webRequest,
                httpServletResponse)
        {
            @Override
            public String encodeRedirectURL(final CharSequence relativeURL)
            {
                return new UrlRenderer(webRequest).renderFullUrl(Url.parse(relativeURL));
            }
        };
    }

UPDATE
Other solution, instead of code change, is to set the following property in the webcontainer (works in 8.5.5.3):

<webContainer com.ibm.ws.webcontainer.redirectwithpathinfo="true" />
Gas
  • 17,601
  • 4
  • 46
  • 93