At the point when you're redirecting to the login page, you need to save the current request URI. You're likely using a Filter to perform the login check and the redirect. In that case, you can use HttpServletRequest#getRequestURI() to obtain the current request URI:
String requestURI = request.getRequestURI();
You could either pass it as a request parameter in the redirect URL or store it in the session. Passing as a request parameter is the safest:
response.sendRedirect(request.getContextPath() + "/login.jsf?from=" + URLEncoder.encode(requestURI, "UTF-8"));
In the bean associated with the login page, you could set it as a managed property or a view parameter. Let's assume that the bean is view scoped so that you can perform nice ajax actions/validations and like. In that case, the view parameter is the only neat way:
<f:metadata>
<f:viewParam name="from" value="#{login.from}" />
</f:metadata>
Then, when the real login succeeds, you can redirect to that URI by ExternalContext#redirect():
public void login() throws IOException {
// ...
FacesContext.getCurrentInstance().getExternalContext().redirect(from);
}
(if necessary supply a default target for the case that from is null)