Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicket + WAS: calling url causes a redirect to a wrong URL causing 404

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.

like image 789
Kate Danes Avatar asked Dec 05 '25 17:12

Kate Danes


1 Answers

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);
        }
    }

    /* *********************************************** */
}
like image 186
Glenn Avatar answered Dec 09 '25 14:12

Glenn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!