Hi,

How do I add a cookie to a URL redirect response? I started with the
following class:

public class RedirectToUrlWithHandlerException extends
ReplaceHandlerException {
...
    
    public RedirectToUrlWithHandlerException(final String redirectUrl,
final int statusCode, final IRequestHandler handler) {
        super(new RedirectRequestHandler(redirectUrl, statusCode){
            @Override
            public void detach(IRequestCycle requestCycle) {
                super.detach(requestCycle);
                handler.detach(requestCycle);
            }
            @Override
            public void respond(IRequestCycle requestCycle) {
                super.respond(requestCycle);
                handler.respond(requestCycle);
            }
        }, true);
    }
}


and in the page:

        throw new RedirectToUrlWithHandlerException(targetUrl, new
IRequestHandler(){
            @Override
            public void respond(IRequestCycle requestCycle) {
                // Set cookie
                cookieUtils.save(name, value);
            }

            @Override
            public void detach(IRequestCycle requestCycle) { }
        });

with cookieUtils:

        instance.cookieUtils = new CookieUtils(cookieDefaults){
            @Override
            protected void initializeCookie(Cookie cookie) {
                super.initializeCookie(cookie);
                cookie.setPath("/");
            }
        };


Still no cookie in the response.

I know this is a tricky issue where older browsers don't always
cooperate, but the page being redirected to can't set the cookie
because the cookie is used to transfer information to it.

Many thanks,

Bernard

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

Reply via email to