aspose file tools*
The moose likes Struts and the fly likes struts(jsp forward to Action?) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts(jsp forward to Action?)" Watch "struts(jsp forward to Action?)" New topic
Author

struts(jsp forward to Action?)

Pourang Emami
Ranch Hand

Joined: Sep 21, 2002
Posts: 127
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


Best Regards,<br />Pourang Emami
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5270
    
  10

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
I love it when you reference my work!


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Pourang Emami
Ranch Hand

Joined: Sep 21, 2002
Posts: 127
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts(jsp forward to Action?)