File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Multiple Controller Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple Controller Servlet" Watch "Multiple Controller Servlet" New topic

Multiple Controller Servlet


Joined: May 26, 2004
Posts: 4
Can J2EE web application contains many controller servlets?

Thank you in advance.


Joined: May 26, 2004
Posts: 4
Ok let me pull this way since this is a question of wide spectrum.

We have J2EE application which is comprises of multimple modules but basically grouped together as a single application and we have our base servlet which we are extending from ActionServlet.

We have a RequestProcessor class configured and I know that this actually does the controller functionality since we are using Struts1.1.

My question is that given then above scenario can we have multiple controller servlet for this J2EE application ? if yes, How could I impelement the same?

Thank you in advance.

David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
You could, but you would have to map a different extension to each controller servlet. This is generally discouraged as it makes the app a mess to try and follow.

Instead, look into the modules feature of Struts. You can create separate modules that each have their own struts config file and correspond to separate paths in the URL, such as

Because each module is independent, you can specify and maintain all the configuration properties separately as you currently are without resorting to a kludge.

"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The team, Newsletter 039.

Joined: May 26, 2004
Posts: 4
I appreciate your comprehensive reply. By looking at your point I assumed that theoritically an J2EE application can have many Controller Servlets configured though it is not recomended to do so.

I agree. Here's the link:
subject: Multiple Controller Servlet
Similar Threads
Design Pattern at Struts
difference in patterns
MVC or Moderate pattern for GUI?
Struts Action class and Action Form
WA #1.....word association