The multi-app functionality still uses a single servlet - the apps are 
logically, but not physically, separate. Also, Struts figures out the 
mappings, so you only register a single servlet mapping.

Here is something closer to what you want for the Struts configuration:

   <servlet>
     <servlet-name>action</servlet-name>
     <servlet-class>org.apache.struts.tiles.ActionComponentServlet</servlet-class>

     <init-param>
       <param-name>config/subapp1</param-name>
       <param-value>/docroot/subapp1/struts-config.xml</param-value>
     </init-param>
     <init-param>
       <param-name>config/subapp2</param-name>
       <param-value>/docroot/subapp2/struts-config.xml</param-value>
     </init-param>

   </servlet>

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

This configuration will map a URL like this:

   http://yourhost/yourapp/subapp1/youraction.do

to an action in subapp1's struts-config.xml file with a path of 
"/youraction". The mapping to subapp1 is done automagically by the Struts 
controller, and all the appropriate sub-app-specific resources, etc., are 
made available for the processing of that request.

One very important note about the above configuration: The Struts multi-app 
support is designed to accomodate a default sub-app, which works the same 
way as a Struts app not using the multi-app support. In this case, the init 
param would be just "config", and it would process requests of the form:

   http://yourhost/yourapp/youraction.do

Also, any requests that cannot be matched to an explicit subapp will be 
looked up in the default sub-app.

I have not personally tried writing an app with multiple sub-apps and no 
default sub-app, but it should work. The above is just something you need 
to be aware of.

By the way, I left out the Tiles configuration, since I'm not sufficiently 
familiar with it, especially in a multi-app environment.

--
Martin Cooper


At 01:55 PM 4/11/02, Struts Newsgroup wrote:
>Subject: Configuring sub-applications
>From: Bill Wohler <[EMAIL PROTECTED]>
>  ===
>   Let's say I have the following goals:
>
>   1. I want the following URLs:
>
>     http://host/app/subapp1/someaction
>     http://host/app/subapp2/someaction
>
>   2. I want the subapps to have their own action namespace.
>
>   3. I want to break up the configurations (struts-config.xml and
>   tile-defs.xml) for the subapps. This goal is up for negotiation if
>   necessary.
>
>   I thought my web.xml might look like this:
>
>     <web-app>
>       ...
>       <servlet>
>         <servlet-name>subapp1</servlet-name>
>         <servlet-class>
>           org.apache.struts.tiles.ActionComponentServlet
>         </servlet-class>
>
>         <init-param>
>           <param-name>config</param-name>
>           <param-value>/docroot/subapp1/struts-config.xml</param-value>
>         </init-param>
>         <init-param>
>           <param-name>definitions-config</param-name>
>           <param-value>/docroot/subapp1/tile-defs.xml</param-value>
>         </init-param>
>         ...
>         <load-on-startup>2</load-on-startup>
>       </servlet>
>
>       <servlet>
>         <servlet-name>subapp2</servlet-name>
>         <servlet-class>
>           org.apache.struts.tiles.ActionComponentServlet
>         </servlet-class>
>
>         <init-param>
>           <param-name>config</param-name>
>           <param-value>/docroot/subapp2/struts-config.xml</param-value>
>         </init-param>
>         <init-param>
>           <param-name>definitions-config</param-name>
>           <param-value>/docroot/subapp2/tile-defs.xml</param-value>
>         </init-param>
>         ...
>         <load-on-startup>2</load-on-startup>
>       </servlet>
>
>       <servlet-mapping>
>         <servlet-name>subapp1</servlet-name>
>         <url-pattern>/subapp1/*</url-pattern>
>       </servlet-mapping>
>
>       <servlet-mapping>
>         <servlet-name>subapp2</servlet-name>
>         <url-pattern>/subapp2/*</url-pattern>
>       </servlet-mapping>
>       ...
>     </web-app>
>
>   First, is the correct way to achieve my goals? It might not be,
>   because unfortunately, I'm getting this message for all URLs in
>   subapp1:
>
>     The request sent by the client was syntactically incorrect
>     (Invalid path /someaction was requested).
>
>   And for URLs in subapp2:
>
>     The requested resource (/subapp2/someaction) is not available.
>
>   However, if I add the following to /index.jsp and view that, I get
>   a view of the page:
>
>     <tiles:insert definition="subapp1.page1" />
>
>   However, the following errors appear in the page:
>
>    [ServletException in:/docroot/subapp1/someaction/content.jsp]
>    Cannot retrieve mapping for action /someotheraction
>
>   And if I put the following in index.jsp:
>
>     <tiles:insert definition="subapp2.page1" />
>
>   I get this:
>
>     javax.servlet.ServletException: Error -  Tag Insert : Can't get
>     definition 'subapp2.page2 '. Check if this name exist in
>     definitions factory.
>
>   If I rip out the servlet and servlet-mapping stanzas for subapp2,
>   then subapp1 works just fine.
>
>   The Tomcat 4.0.2 log files offer no additional information.
>
>   I'd appreciate any suggestions you might have. I searched but
>   couldn't find any examples like this.
>
>--
>Bill Wohler <[EMAIL PROTECTED]>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
>Maintainer of comp.mail.mh FAQ and mh-e. Vote Libertarian!
>If you're passed on the right, you're in the wrong lane.
>
>--
>To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to