Hi guys,

I just plopped the nightlies of Feb 12 into a project (struts_action) and

<jsp:include page="/do/myAct" />

doesn't work for me (:
Always did with 1.1, 1.2 I think I had previously raised a bug on this, but I honestly don't remember.
It affects the use of actions within c:import and Tiles definitions, too.

Can anyone confirm this? Should be easy to reproduce on the mailreader app, for example. Just add a front jsp leading to an action URL.

Please judge whether that is fundamental enough to go into 1.3 final.

Hope this is no disturbance for the valentine's day present.

Please find my personal patch for this attached. Here, we flip it in by modifying chain-config.xml.

Wolfgang


/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.rsp.framework.struts.command;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.chain.commands.AbstractPerformForward;
import org.apache.struts.chain.contexts.ActionContext;
import org.apache.struts.chain.contexts.ServletActionContext;
import org.apache.struts.config.ForwardConfig;
import org.apache.struts.config.ModuleConfig;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>Perform forwarding or redirection based on the specified
 * <code>ForwardConfig</code> (if any).</p>
 *
 * @version $Rev: 370938 $ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005)
 *          $
 */
public class IncludeCompatiblePerformForward extends AbstractPerformForward {
    // ------------------------------------------------------- Protected Methods

    /**
     * <p>Perform the appropriate processing on the specified
     * <code>ForwardConfig</code>.</p>
     *
     * @param context       The context for this request
     * @param forwardConfig The forward to be performed
     */
    protected void perform(ActionContext context, ForwardConfig forwardConfig)
            throws Exception {
        ServletActionContext sacontext = (ServletActionContext) context;
        String forwardPath = forwardConfig.getPath();
        String uri = null;

        if (forwardPath == null) {
            // Retrieve internal message resources
            ActionServlet servlet =
                    (ActionServlet) sacontext.getActionServlet();
            MessageResources resources = servlet.getInternal();

            throw new IllegalArgumentException(resources.getMessage(
                    "forwardPathNull"));
        }

        ModuleConfig moduleConfig = context.getModuleConfig();

        // Resolve module-relative paths
        if (forwardPath.startsWith("/")) {
            uri = RequestUtils.forwardURL(sacontext.getRequest(),
                    forwardConfig, moduleConfig);
        } else {
            uri = forwardPath;
        }

        HttpServletRequest request = sacontext.getRequest();
        
        // Patched by Wolfgang Gehner [EMAIL PROTECTED]: use of actions within tiles, jsp:include or c:import requires to 
        // convert forward (w/o redirect) to an include if response has been committed 
        HttpServletResponse response = sacontext.getResponse();
        if (response.isCommitted() && !forwardConfig.getRedirect())
        {
        	RequestDispatcher rd = sacontext.getContext().getRequestDispatcher(uri);
	        if (rd == null) {
	            response.sendError(
	                HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
	                "Error getting RequestDispatcher for " + uri);
	            return;
	        }
	        rd.include(request, response);
	        return;
        }

        // Perform redirect or forward
        if (forwardConfig.getRedirect()) {
            if (uri.startsWith("/")) {
                uri = request.getContextPath() + uri;
            }

            sacontext.getResponse().sendRedirect(sacontext.getResponse()
                    .encodeRedirectURL(uri));
        } else {
            RequestDispatcher rd =
                    sacontext.getContext().getRequestDispatcher(uri);

            rd.forward(request, sacontext.getResponse());
        }
    }
}

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

Reply via email to