Suppose, from one Action class, i called the servlet & then after successfull execution of the servlet, I want to redirect the user to the previous page. Then, what code I need to write?
Another thing, if any annonymous user tries to post topic/reply, then, how can i redirect him to the login page & after successfull authentication, how can I redirect hime to the specified page (just like the jforum.net's forum is working).
Generally such stuff is done either via the Referer: HTTP tag or by the redirecting servlet using the Request object to supplying a parameter in some way.
E.g., if I go to protected URL x, the security filter may forward the user to the login page via either an internal redirect (using the RequestDispatcher.forward) or an HTTP redirect, (using the response.sendRedirect method).
With the internal method, the Request object is the same as the original and all info, e.g. requestingURL, queryString, and the like, about the original page is there. This can be used to store it either in the session or as a hidden field on the login form. Then the authenticating servlet can use that info to redirect a valid user to the original page.
With the external method, you should be able to use the request.getHeader method to get the referer HTTP header info. Note that while most browsers will supply this info, it's not really required. So, code for a possible null value (e.g., have a default page if it can't be determined). This can be used the same way as the internal forward to be passed on to the authenticating servlet. [originally posted on jforum.net by monroe]
i am using jforum 2.1.7 and I want to redirect the anonymous user to the login page while he wants to post a message and after successfull authentication, i want the user to redirect to the previous page.
Postaction might be the place to look. when he figures otu the user is anonymous, throw the necessary information for writing into the session (for instance as new object)... then send a redirect to the login page, and after the login action, check in the session if the object exists, if so, read it, put the actions to the request context and kill the session information ...
I use such a redirection feature when signing a user on for the first time (in SSO environment). If the user had to be created, he will be redirected to the user profile, instead of the forum start page. I do that by adding/replacing the action and module parameter to the request. [originally posted on jforum.net by Sid]