This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Since Struts is only a particular way of creating a J2EE web application, you can intercept the 404 error in exactly the same way that you would in any other J2EE web application. There is no difference for a Struts application.
There is nothing unique to Struts about this. It's how you would redirect an HTTP error in any J2EE web application using servlet 2.2 and above. [ March 09, 2006: Message edited by: Merrill Higginson ]
Joined: Feb 15, 2005
This is a little more complicated than I originally thought. While the method used in my previous post will work if the URL is xyz.jsp, or xyz.htm, it will not work for xyz.do if xyz is not a valid action path.
The reason for this is that I've specified in my web.xml file that the Struts action servlet is to get called for any URI ending in .do. So, for any requests ending in .do, the struts ActionServlet takes over, and when it doesn't find an Action path, it sends a 404 error back to the browser.
If you want to change this behavior you will have to override the processMapping() method in the org.apache.struts.action.RequestProcessor class.