Hello friends, I have very little experience in struts 2 & I have this typical requirement where I feel that I have to redirect form the prepare() method when the user is not logged in (by checking whether some session entries present or not). Actually I am trying to avoid repetitive session checking & redirecting at the beginning of every action method, for example public String listUsers() throes Exception { //if (session.get("userType") != null && session.get("userType").equals("admin")) //then show the result //otherwise redirect to the login page }
public String viewDetails() throes Exception { //again code for the same checking } so I thought that since the prepare() method is being called every time some action is being mapped to a method in this class so why not put the code for checking & redirecting inside of prepare like, public void prepare() throws Exception { //if the user is not logged in //redirect to the login page } But the problem is that I cannot return any string (which I can specify as result of type "redirect-action" in the struts.xml file)since this function has return type void also I could not find any method to redirect forcibly. So, my question is whether it is possible to redirect form any method which has not been mapped as an action at all? if it can be done then how to do it? Any ideas regarding this problem would really help. Thanks in advance -- View this message in context: http://www.nabble.com/how-to-redirect-from-prepare%28%29-method-in-struts-2-tp21643785p21643785.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org