wood burning stoves 2.0*
The moose likes Struts and the fly likes Global forwards in Struts modules Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Global forwards in Struts modules" Watch "Global forwards in Struts modules" New topic
Author

Global forwards in Struts modules

Matt Phipps
Greenhorn

Joined: Aug 25, 2004
Posts: 8
Hi,

I'm tring to learn about modular struts apps but I'm having trouble with a global forward to my home page (index.jsp).

I have a global struts-config.xml with: as a global forward and as an action mapping in the same struts-config.xml.

When I place a in the jsp's in the modules the jsp will not run with an "Cannot retrieve ActionForward named home" error.

Is this because index.jsp isn't in a module? If so how can I overcome this?

Thanks,
Matt
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
The Struts custom tags will look for a ModuleConfig object that is placed in request scope. This object relates to a struts config file. If a URL refers to a module, the request will contain a ModuleConfig object for that module, regardless of where your JSP page is located. Thus, the html:link tag that uses the ModuleConfig object may be looking in the wrong Struts config file for your action mapping.


Anthony W.<br />MCP, SCJP 1.4, SCJD, SCWCD 1.3, SCWCD 1.4, SCBCD
Matt Phipps
Greenhorn

Joined: Aug 25, 2004
Posts: 8
OK,

So should I add the action forward to each modules struts-config.xml? If so then how do I get around the relative path URL? Will the module assume the path is relative to the itself even though my index.jsp is in a folder one layer up? Is it just "../index.jsp"?

Also, how would you link from one module to another? Would you enter the module name in the url or again would this be seen as a path relative to the current module?

Thanks,
Matt
Anthony Watson
Ranch Hand

Joined: Sep 25, 2003
Posts: 327
I prefer to use JSTL tags in favor of Struts custom tags where there is an overlap in functionality. Struts 1.24 has added a 'module' attribute to some of its custom tags, but I'm not sure what version you are trying to use. My advice is to start working with JSTL. Here's an example of rendering an image in the public module using JSTL:
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Global forwards in Struts modules