First, it's important to note that regardless of how many frameworks,
servlets, filters, or anything else we use, if it's under the same
application-root, and shares the same web.xml, then it's all one web
app. If we like, we can run Tapestry, Wicket, and Struts all in the
same web application. All of these components are simply members of
the same web application. Members of the same web application can
share access to servlet, session, and request contexts. Members of
different applications cannot.

The cannonical Struts 2 approach would be to consider A and B
different "namespaces" rather than different "applications". The
framework is designed so that we can write actions and pages without
reference to the action extension or to the namespace (except when
changing namespaces). Meaning we can change the action extension or
the namespace (subdirectory) without changing much else.

Depending on your container, you might be able to place different
namespaces in different WARs. Deploying as plugins would be another
solution, but that only works well with Velocity or Freemarker
templates. The better solution for the use case described might be
portlets.

 * http://struts.apache.org/2.x/docs/portlet-tutorial-webwork-22.html

(Obviously, this page still needs to be updated to refer to Struts 2.)

But, yes, in Struts 2.0.x, there is one extension setting per
DispatchAction filter, and only one filter per application is
supported. In Struts 2.1, multiple filters will be supported.

Struts 2.0.x does support multiple extensions. To answer both .do and
.action, we can configure Struts 2 with a list of extensions.

<struts>
    <constant name="struts.action.extension" value="action,do" />

The default struts.xml could simply include the A and B
configurations, which could each be configured as a separate
namespace. But that's not going to do much for deployment issues.

-- HTH, Ted
 * <http://www.StrutsMentor.com/>


On Dec 7, 2007 6:03 AM, Alexis Pigeon <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm facing a problem, surely due to an error in my configuration, but
> can't find out a solution for it...
>
> I would like two webapps, both built upon Struts 2 (2.0.11), to have
> different action extensions:
> - webapp-A will have *.do
> - webapp-B will have *.action
>
> Both webapps have the same web.xml in their respective WEB-INF (see below).
>
> In webapp-A, struts.properties goes like this :
>
> struts.action.extension=do
>
> whereas in webapp-B, it goes like that :
>
> struts.action.extension=action
>
> Now, when accessing webapp-A/myAction.do, no action is reached. No
> error message, nothing in the logs, just a blank page in the browser.
> Strangely, webapp-A/myAction.action hits the correct action, and the
> page renders correctly. But the rendered html form is pointing to *.do
> actions, and you get the above-mentionned blank page when submitting
> the form.
>
> On the other hand, webapp-B is working like a charm, all with *.action 
> actions.
>
> The struts2-core-2.0.11.jar is placed in the shared/lib folder in the
> Tomcat (5.5.25) hierarchy.
> If I place the jar in the respective WEB-INF/lib/ folder instead, all
> works as expected. However, such a solution is not an option for me
> (because of the size of the resulting war file, tedious upgrade
> process, etc...).
>
> Could it be that the action extension is defined at startup time as a
> global variable, shared by all the webapps if the struts library is
> placed in the shared/lib folder? Is there a way to force the webapps
> to always read the action extension from their own struts.properties
> file?
>
> Thanks for the help,
> alexis
>
> ------------------------------------------------------------------------
> web.xml file, same content for both webapps
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app version="2.4"
>         xmlns="http://java.sun.com/xml/ns/j2ee";
>         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>
>     <filter>
>                 <filter-name>struts-cleanup</filter-name>
>                 <filter-class>
>                           org.apache.struts2.dispatcher.ActionContextCleanUp
>                 </filter-class>
>         </filter>
>     <filter>
>                 <filter-name>struts2</filter-name>
>                 <filter-class>
>                     org.apache.struts2.dispatcher.FilterDispatcher
>                 </filter-class>
>     </filter>
>
>     <filter-mapping>
>         <filter-name>struts-cleanup</filter-name>
>         <url-pattern>/*</url-pattern>
>     </filter-mapping>
>     <filter-mapping>
>                 <filter-name>struts2</filter-name>
>                 <url-pattern>/*</url-pattern>
>     </filter-mapping>
>
>         <welcome-file-list>
>                 <welcome-file>/jsp/index.jsp</welcome-file>
>         </welcome-file-list>
> </web-app>

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

Reply via email to