• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts(jsp forward to Action?)

 
Pourang Emami
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help would be greatly appreciated on the following scenario:
Client's link --------> some.jsp -----forward req -----> SomeAction
What should be the path to the SomeAction in the following tag inside some.jsp(So that the req's parameters get captured by SomeForm):
<jsp:forward page="pathToAction?"/>
Thank you
 
Junilu Lacar
Bartender
Pie
Posts: 7293
44
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this thread: http://www.coderanch.com/t/47361/Struts/Advanced-Action-Classes-Article-DispatchAction for a link to an article that discusses some issues that you may find relevant.
Basically, you should avoid linking to JSPs. Always link to Actions (*.do). jsp:forward takes on Controller responsibilities which are better left to the Actions. Keep JSPs focused on presentation.
 
Rick Hightower
Author
Ranch Hand
Posts: 350
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I love it when you reference my work!
 
Pourang Emami
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you dear Junilu for your great reference, and congrad to you Rick because of your awesome job.
For my case I persued SwitchAction approach and changed my scenario to:
client -----> action ------switch(forward)-----> mediatery jsp ---forward-----> view.jsp
but struts giving me the following message:
Jan 17, 2004 11:31:19 AM org.apache.struts.action.RequestProcessor process
INFO: Processing a 'POST' for path '/switch'

Jan 17, 2004 11:31:20 AM org.apache.struts.actions.SwitchAction execute
***SEVERE: Invalid sub-application prefix /admin was specified***
*******************************************
What's wrong? I have this configurations:
Inside struts-config.xml:
<form-beans>
<form-bean name="AddTopicForm" type="actions.AddTopicForm"/>
</form-beans>
<action-mappings>
<!-- Add New Topic Scenario ************ -->
<action path="/switch" type="org.apache.struts.actions.SwitchAction">
</action>

<action path="/addTopic" attribute="AddTopicForm" name="AddTopicForm"
scope="request" type="actions.AddTopicAction">
<forward name="proceed" path="/switch.do?
page=/uploadFile.do&prefix=/admin"/>
</action>
<!-- /Add New Topic Scenario ************ -->
</action-mappings>
<message-resources parameter="mypackage1.ApplicationResources"/>
*******************************************
And inside struts-config-admin.xml:
<form-beans>
<form-bean name="AddTopicForm" type="actions.AddTopicForm"/>
</form-beans>

<action-mappings>
<action path="/uploadFile" forward="/pages/addTopicTile.jsp"
name="AddTopicForm" parameter="/pages/addTopicTile.jsp"
scope="request" />

</action-mappings>
<message-resources parameter="mypackage1.ApplicationResources"/>
Appreciate your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic