I have been working on setting up a multi-app application by using multiple config/ 
init-param elements and struts configuration files. It seems to me that there is a 
small problem in the RequestUtils class when a request URI is used to locate the 
proper sub-application so that an ApplicatonConfig object can be located for the 
sub-application.

Here's a snippet of the selectApplication method in the RequestUtils class:

public static void selectApplication(
                   HttpServletRequest request,
                   ServletContext context) {

 // Acquire the path used to compute the sub-application
 String matchPath = request.getServletPath();

 // Match against the list of sub-application prefixes
 String prefix = "";
 String prefixes[] = getApplicationPrefixes(context);
 for (int i = 0; i < prefixes.length; i++) {
   if (matchPath.startsWith(prefixes[i])) {
     prefix = prefixes[i];
     break;
   }
 }
 etc...

It's my understanding through debugging that the matchPath field will be assigned the 
sub-application prefix like "/order". This should a value that is suffixed to a config 
init-param for the sub-app in web.xml.
(My first assumption that could be wrong).

If this is true and the field matchPath contains the sub-app prefix, then I don't 
think the line:

   matchPath.startsWith(prefixes[i])) 

will ever return true, because the prefixes array should contain prefixes that have 
the Action.APPLICATION_KEY prepended to the front of the prefix when it's added to the 
ServletContext in the initApplicationConfig method. This means that we are checking 
whether some prefix  like "/order" or "/checkout" starts with the 
Action.APPLICATION_KEY + prefix.

Instead, the code falls through and the default application is selected every time 
because the prefix is assigned a default value of "" in this method.

Shouldn't the check be something like:
prefixes[i].endsWith( matchPath )

I apologize if there is something that I missed, but I've been looking at it for a 
couple of days and my mind is gone trying to solve this problem.

BTW, my web.xml is:
<init-param>
 <param-name>config</param-name>
 <param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>    

<init-param>
 <param-name>config/order</param-name>
 <param-value>/WEB-INF/struts-order-config.xml</param-value>
</init-param>

and the URL that I'm entering is something like:
  localhost/storefront/order/addItemToCart
where storefront is the web context.

Thanks,
Chuck Cavaness
--
Posted via jApache.org

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

Reply via email to