This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a program that is used to generate a number of reports. The initial JSP has a number of combo boxes where a user chooses the type of report to generate, startdate and enddate.When the JSP is submitted, the main Action Servlet should now use case statement in determining which specific servlet to call so that execution happens and the result of this specific servlet be now forwarded to a JSP.This means that for every report selected, it has its own servlet to populate the result. in diagrammatic form i need to implement something like:
initial JSP- main action servlet- specific action servlet - final JSP.
How do i use the mapping.findForward method in the main servlet to forward to a specific servlet based on what kind of report has been chosen, so that that servlet can do the manipulation before results are sent to the final JSP.
You don't need to mess around with the ActionServlet to do what you are trying to accomplish. First make sure all your servlets are set up in your web.xml. For example let's say you have the following:
Next add them as forwards, either global or local to an action, in your srtuts-config.xml. I'll use global forwards to demonstrate.
Now create an Action that your JSP form will submit to. It's inside this Action where you determine what Servlet to use based on the input from the form.
Based on what I understood from your post, this is the "Struts" way to solve the problem you have described.