I am using PrettyFaces in my JSF application. The site requires authentication to access some pages, so I'm using a listener (prerender view) that checks whether the user is logged in. So, if the user tries to access /foo (/foo.jsf before PrettyFaces), I redirect to /login.
However, I want to redirect them to their initial destination, so I want to attach a request parameter "next" so that I redirect the user to /login?next=/foo instead. Unfortunately, I can't get the original requestURI from the request object, the uri string in the following code is /appname/foo.jsf instead of /appname/foo
ctx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest) ctx.getRequest();
String uri = request.getRequestURI();
Is there a way to retrieve the original URI path?