hi,

i have a requirement where we need to use two Controllers (one for each module) 
in our project.

my web.xml looks like this..........

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>

<servlet>
<servlet-name>controller1</servlet-name>
<servlet-class>com.test.struts.Controller1</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config1.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>controller2</servlet-name>
<servlet-class>com.test.struts.Controller2</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/config2.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>controller1</servlet-name>
<url-pattern>/controller1/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>controller2</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<taglib>
<taglib-uri>/bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

</web-app>

..both controller1 and controller2 extend ActionServlet. when using controller2 
i use the URL 
http://localhost:9080/MultipleControllers/Welcome.do

(the struts-config snippet corresponding to Welcome.do is shown below
)

<action

path="/Welcome"

type="org.apache.struts.actions.ForwardAction"

parameter="/pages/Welcome.jsp"/>


and it works fine.....next i want to use the controller1 and i use the url

http://localhost:9080/MultipleControllers/controller1/WelcomePage

(the struts-config snippet corresponding to "WelcomePage" is shown below
)
<action

path="/WelcomePage"

type="org.apache.struts.actions.ForwardAction"

parameter="/WorkFlow/pages/WorkFlowWelcome.jsp"/>


..now it gives me an error 

org.apache.struts.action.RequestProcessor Invalid path /WorkFlow/WelcomePage 
was requested

i dont know why this error comes up.

i also wanted to clear some of my doubts connected with the same.

1)Is it possible to have Multiple Controllers in a single web-applicaion?
(both these controllers are extended from the ActionServlet)

2)if Yes, can you please post some sample code which would help me in 
understanding the same?

3)Can this Muliple Controller concept be used along with the struts modules?
(or to rephrase...Can the struts modules concept work with more than one 
Controller?)

I am stuck with this for quite some time. If any of you have faced similar 
situations...please guide me or help me with some code snippets.

THanks in advance
-Amith 

Reply via email to