• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts2 - Not forwarding to another action using type="Dispatcher"

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am worlimg with Strts2. I am new to struts2 as well. Facing a lot of problems in development using struts2. Need your help in dispatching an action from struts.xml. Please help me if anyone have faced similar kind of problem

If I use type="dispatcher" in <result> tag, the action is not dispatched to the specified action. It's not throwing an exception as well. But if I use type="redirectAction", the action is redirected, but my request object is lost. So I don't want to redirect.
I want to farward the action with out losing the request object.

Also if I specify a JSP page in the dispatcher, it's working fine
ie)
Working


Working


Not Working



I am using jdk1.6,struts2.1.6, weblogic10.3. Please help me to solve this problem
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AFAIK "dispatcher" is just using a regular forward, which means it can only access servlet resources (JSP, servlet, etc.)
 
udhaya kanagaraj
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks David.

Could you please suggest me the alternative for using dispatcher

I am struggling with this problem for the past one week.

Please help me to solve this issue.


Thanks and Regards,
Udhaya
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Figure out different program logic.

Depending on your specific needs, which I obviously don't know, you might be able to use dynamic results (see here and here), keep data in the session, possibly use action chaining (NOT recommended), or some other solution.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am struggling with the same problem , Did any got the solution. ?

I have a problem with forwarding the request to an action.
I am using validations for the fields mention on the form , once validation fails as struts defined it will check for result name "Input".
If the result name "Input" is defined with result type "redirect-action" as shown below , this will forward to the mention action with new request.
<result name="input" type="redirect-action">
Is there any way where I can forward to an action , but still can use the old request object, throught will I can display the invalid values that user enter.
I tried all the result type like :
dispatcher --- Dispacther uses the old request object but the location must be a view not an action.
Chain --- chain uses the old request object but it is excuted irrespective of what happen , life even if the validation pass chain is going to exucute.
redirect -- same as redirect-action.
Do anybody got such a problem earlier. ?
Temp solution :
I am setting the values in the session in the getter method of the object. and setting back to the new request removing it from the session.
But i think this is a temp solution , there should be a direct solution where we can speicfy in resut-type like redirect with the old request object.
Please any Inputs are highly appreicated.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Topic looks old but still replying here if someone facing same issue.
I tried defining the new global result type as <result-type name="forwardAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult" /> and used this result type in the action result type where it is required to forward to another action. e.g
<action name="someAction" class="someActionClass">
<result name="success" type="forwardAction">${nextAction}</result>
</action>
Worked for me, but not sure if that is correct way.
 
Parag Bhole
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Earlier post was wrong, actually org.apache.struts2.dispatcher.ServletActionRedirectResult is already present in struts-default "redirectAction".
struts-default "chain" result type is forwarding the action.
 
reply
    Bookmark Topic Watch Topic
  • New Topic