File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Mapping a main Action Servlet to other servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Mapping a main Action Servlet to other servlets" Watch "Mapping a main Action Servlet to other servlets" New topic

Mapping a main Action Servlet to other servlets

vernon mweetwa

Joined: Nov 26, 2004
Posts: 24

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.

Jason Menard

Joined: Nov 09, 2000
Posts: 6450
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.
I agree. Here's the link:
subject: Mapping a main Action Servlet to other servlets
It's not a secret anymore!