Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Global forwards in Struts modules

 
Matt Phipps
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matt Phipps
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic