I have a JSF web application I need to provide functionality as mentioned below:

1. In order to comment on something user must be logged in
2. If he is not logged in then 'Click here to login' takes him to the login page
3. Successfull login must redirect him to the url from where he navigated to login page

Is there any way this can be achieved?