Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

struts(jsp forward to Action?)

 
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
 
Marshal
Posts: 15883
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this thread: https://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.
 
Author
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.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic