File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes ensuring valid forwards Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ensuring valid forwards" Watch "ensuring valid forwards" New topic
Author

ensuring valid forwards

Dan Tenenbaum
Greenhorn

Joined: Apr 19, 2005
Posts: 6
My codebase has a lot of lines like this in struts actions:
return mapping.findForward("foo");

If I make a typo and it turns out that "foo" is not a valid forward according to the struts config file, when I hit the action in the browser, I get a blank page. Not my designated error page.

Is there some sort of struts-centric way to ensure that an exception is thrown and my error page appears? I just want to know if there is an existing mechanism to do this. I could easily write a method to do it (to be called instead of mapping.findForward()) but it seems that this is something Struts should handle.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
the closest struts handles unknown is the action mapping attribute 'unknown' which becomes the action to call when a xxx.do is not found. i don't believe there is such a thing for forwarding. you'll need to write your own. -/a


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Jack Wiesenthaler
Ranch Hand

Joined: Jul 26, 2001
Posts: 75
One way is possibly defining your own exception class and throwing it when a mapping.findforward returns a null ActionForward. Then in the action mapping within struts-config you can use the exception tag with your exception type mapped to the specified error jsp page.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ensuring valid forwards