Re: Forward a action from one action programmatically in STruts 2.0
Hi Rene, It works.Thanks Regards, Arun. Maybe this is the option you are searching for: struts.xml: --- ${targetUrl} in your acme.Action1 class: --- String targetUrl; public String getTargetUrl() { return this.targetUrl; } public String execute() { if (...) { this,targetUrl = "1.jsp"; } else ... } } Regards, - Rene arunkumar S schrieb: Hi, Thanks for the inputs. my req. will not satisfy your suggestion. My req. is I have to load different Jsps depending on the user profile. eg <http://profile.eg/>. for user with profile = "abc", i will have JSps like 1_abc.jsp,2_abc.jsp,3_abc.jsp for user with profile = def , i will have jsps like 1_def.jsp,2_def.jsp etc.. one way of solving this is to mention all the Jsp for users with different profile in the results and then forward it in the action itself. like 1_abc.jsp 1_def.jsp 2_abc.jsp 2_def.jsp return corresponding result in each action based on the users profile. but the pblm here for each action the application developer has to define results for each user. I am thinking of moving this to framework. Below is the new approach. 1.jsp 2.jsp /{1}.jsp Now , in an action1.class & action2.class depending on the user profile i construt 1_abc.action or 1_def.action and 2_abc.action or 2_def.action respectively . and if i can forward with 1_abc.action the below definition present in the STruts.xml will take care of forwarding it to 1_abc.jsp /1_def.jsp depending on the user automatically. /{1}.jsp FOr this i need to programmatically forward to an action so that i can leverage the above mentioned facility. I hope i have made things clear.Let me know if have any suggestions. Regards, Arun. The way I solve this is by returning the value you want and setting up the action chain on struts.xml file: Example: class MyAction 1 .. { public String execute(){ if(foo) return "foo"; else return "bar"; } Then on the Strutus XML file: FooAction BarAction ... PS. Make sure you use type="chain"! Hope this helps. Harring On 3/15/07, arunkumar S <[EMAIL PROTECTED]> wrote: Hi, I have a requirement where in the action has to be forwarded based on certain runtime conditions.The destination will be decided only on the runtime. --- if(Input = "Case1" ) forward action1 else forward action2. --- Basically i want to acheive a simple forward( requestdispatcher.forward() ) in ActionClass in Struts 2.0. How can we acheive this in Struts 2.0. I dont have any API to acheive this. Any inputs pls? Regards, Arun
Re: Forward a action from one action programmatically in STruts 2.0
Hi, Thanks for the inputs. my req. will not satisfy your suggestion. My req. is I have to load different Jsps depending on the user profile. eg <http://profile.eg/>. for user with profile = "abc", i will have JSps like 1_abc.jsp,2_abc.jsp,3_abc.jsp for user with profile = def , i will have jsps like 1_def.jsp,2_def.jsp etc.. one way of solving this is to mention all the Jsp for users with different profile in the results and then forward it in the action itself. like 1_abc.jsp 1_def.jsp 2_abc.jsp 2_def.jsp return corresponding result in each action based on the users profile. but the pblm here for each action the application developer has to define results for each user. I am thinking of moving this to framework. Below is the new approach. 1.jsp 2.jsp /{1}.jsp Now , in an action1.class & action2.class depending on the user profile i construt 1_abc.action or 1_def.action and 2_abc.action or 2_def.action respectively . and if i can forward with 1_abc.action the below definition present in the STruts.xml will take care of forwarding it to 1_abc.jsp /1_def.jsp depending on the user automatically. /{1}.jsp FOr this i need to programmatically forward to an action so that i can leverage the above mentioned facility. I hope i have made things clear.Let me know if have any suggestions. Regards, Arun. The way I solve this is by returning the value you want and setting up the action chain on struts.xml file: Example: class MyAction 1 .. { public String execute(){ if(foo) return "foo"; else return "bar"; } Then on the Strutus XML file: FooAction BarAction ... PS. Make sure you use type="chain"! Hope this helps. Harring On 3/15/07, arunkumar S <[EMAIL PROTECTED]> wrote: Hi, I have a requirement where in the action has to be forwarded based on certain runtime conditions.The destination will be decided only on the runtime. --- if(Input = "Case1" ) forward action1 else forward action2. --- Basically i want to acheive a simple forward( requestdispatcher.forward() ) in ActionClass in Struts 2.0. How can we acheive this in Struts 2.0. I dont have any API to acheive this. Any inputs pls? Regards, Arun
Forward a action from one action programmatically in STruts 2.0
Hi, I have a requirement where in the action has to be forwarded based on certain runtime conditions.The destination will be decided only on the runtime. --- if(Input = "Case1" ) forward action1 else forward action2. --- Basically i want to acheive a simple forward( requestdispatcher.forward() ) in ActionClass in Struts 2.0. How can we acheive this in Struts 2.0. I dont have any API to acheive this. Any inputs pls? Regards, Arun