Try with "throw new RedirectToUrlException(destination)" instead of setting
new RequestTarget

On Thu, Mar 24, 2011 at 4:25 PM, Sam Zilverberg <[email protected]>wrote:

> I've got a servlet that serves files.
> It's mounted on /files/* and has a WicketSessionFilter on that same path so
> it has access to the wicket session.
>
> When a user accesses /files/?id=1 the servlet checks that the wicket
> session
> exists, that the user is logged in and some other logic then serves the
> file
> to the user.
> When a user is not logged in, and say comes to this url from a link in an
> email, I'd like the servlet to send him to the login page, then after
> providing credentials I'd like to return to the original url so the file
> will be served.
>
> What is the best way to accomplish this?
>
> So far I tried to redirect like this:
> servlet:
> response.redirect(contextPath + "/login?destination=files/?id=" + id)
> login page after login success:
> if (destination != null)   getRequestCycle().setRequestTarget(new
> RedirectRequestTarget(destination));
> but this failed because the request was redirected twice and it is not
> allowed.
>
> I also tried to forward the request but failed.
>
> Any help would be appreciated!
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to