• 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

How to forward past index.jsp

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
index.jsp
===============================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<logic:forward name="forwardToReportSelect" />
===============================================================

struts-config.xml
===============================================================
<!-- Global Forwards -->
<global-forwards>
<forward
name="forwardToReportSelect"
path="startReportSelect" />
</global-forwards>

<!-- Action Mappings -->
<action-mappings>
<action
path="/startReportSelect.do"
type="IndexAction"
scope="session">
<forward
name="success" path="/teqReport/reportSelect.jsp" />
</action>
</action-mappings>
===============================================================
 
JD Thompson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about the double posts, I accidentally hit the tab/enter in sequence which posted the request incomplete.....


The previous listed the index.jsp I am trying to forward through along with the applicable struts part which I am trying to reach IndexAction.

IndexAction (VERY skeletal!)
==================================================================
public class IndexAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value

try {
// do something here
}
catch (Exception e) {
errors.add("name", new ActionError("id"));
}
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
forward = mapping.findForward("success");
}
return (forward);
}
}
==================================================================

Anticipated action:

1. the index.jsp is called from another site
2. the <logic:forward> tag is executed
3. the global forward then sends control to "startReportSelect.do"
4. the action-mapping for "startReportSelect.do" then calls the Action
5. the Action, "IndexAction", then executes the preprocessing required
6. after the global variables completed, the "reportSelect.jsp" is rendered


Errors received:
Error 404: File not found: null

Oh great Struts Guru, what simple fragment/quote/logic am I missing?

Thanks for your help!!!

Take care!

JD
 
JD Thompson
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I have found a solution [took me two days to work through all of the subleties] and will post it here. I did not find alot of "clear" examples out there so hopefully this will help someone else at least once!

Your index.jsp should be setup as follows:

index.jsp
===============================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<logic:forward name="forwardToGlobalForward" />
===============================================================
NOTE: the name attribute is the name of the GLOBAL FORWARD



Modify your struts-config.xml as follows:

struts-config.xml
===============================================================
<!-- Global Forwards -->
<global-forwards>
<forward
name="forwardToGlobalForward"
path="/actionMappingToGoToNext.do"
redirect="true"/>
</global-forwards>


<!-- Action Mappings -->
<action-mappings>
<action
path="/actionMappingToGoToNext"
type="actionClassToBeExecutedBeforePageRendered">
<forward name="success" path="jspToBeRenderedAndFirstSeenByUser" />
</action>
</action-mappings>

The last thing to be sure of is to reference "success" in your mapping.findForward("success") part of your Action class.

Systems: IBM Rational, Struts 1.1, WebSphere 5.1 Server

In terms of path references, there may be inconsistencies from one IDE to the next where the slash/ is concerned for the path. I found that including it as a relative mark was causing problems in Rational but other online examples with Tomcat had the slash.

I sincerely hope this helps someone else along the way.

Bartender Merrill, I hope I did not overstep my bounds by posting my solution here.

Take care all!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic