hi all,
 
I'm trying to forward from one action to another and get forward exception.
I have a LoginAction which checks all the login data and if it's ok it
should forward the request to HomeAction which prepare data for personal
home page.
 
I see in the logs that the LoginAction is processed succesfully until the
last line which is:
 
return (mapping.findForward("success"));
 
It fails to go to the HomeAction. 
Here is the LoginAction code and struts-config.
 
 
=========== LoginAction.java ===============
 
package sis.web.action;
 
import java.io.IOException;
import java.util.Hashtable;
import java.util.Locale;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.util.MessageResources;
import org.apache.log4j.Category;
 
import sis.web.util.WebUtils;
import sis.web.util.WebKeys;
import sis.client.UserHandler;
import sis.core.SisFinderException;
 

 
public final class LoginAction extends Action {
 

    static Category log = Category.getInstance(LoginAction.class);
    // --------------------------------------------------------- Public
Methods
 
public ActionForward perform(ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
 throws IOException, ServletException {
 
        log.debug("starting");
 
 // Extract attributes we will need
 Locale locale = getLocale(request);
 MessageResources messages = getResources();
 HttpSession session = request.getSession();
 
// check for transaction token (if not exist this is first time, don't show
error
        saveToken(request);
            
        
 // Validate the request parameters specified by the user
 ActionErrors errors = new ActionErrors();
 String username = ((LoginForm) form).getUsername();
 String formPassword = ((LoginForm) form).getPassword();
 
        if (username == null) {
            // check transaction condition
            if (this.isTokenValid(request))
                errors.add("user", new
ActionError("error.username.required"));
            else // first time, just go to jsp
                return (new ActionForward(mapping.getInput()));
        }
        else {
            // get signon handler
            UserHandler userHandler = WebUtils.getUserHandler(session);
        
            String password = null;
            try {
                password = userHandler.getPassword(username);
            } catch (SisFinderException sfe) {
                errors.add("user", new
ActionError("error.user.notfound",username));
            }
        
            if (password == null) {
                errors.add("password", new
ActionError("error.password.required"));
            }
            else if (!password.equals(formPassword))
                errors.add("password", new
ActionError("error.password.mismatch"));
        }
        
 // Report any errors we have discovered back to the original form
 if (!errors.empty()) {
     saveErrors(request, errors);
     return (new ActionForward(mapping.getInput()));
 }
 
 // Save our logged-in user in the session
 session.setAttribute(WebKeys.USER_KEY, username);
 session.setAttribute(WebKeys.PASSWORD_KEY, formPassword);
        log.info("User '" + username + "' logged on in session " +
session.getId());
 
        // Remove the obsolete form bean
        WebUtils.removeFormAttribute(mapping, request);
 
        log.debug("Done removeFormAttribute");
 
        // reset transaction token
        resetToken(request);
        
        log.debug("Done resetToken");

        // Forward control to the specified success URI
 return (mapping.findForward("success"));
 
    }
}
 
=========== struts-config.xml ===============
<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
          " http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";
<http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd> >
 
<struts-config>
 
  <!-- ========== Form Bean Definitions ===================================
-->
  <form-beans>
    <!-- Logon form bean -->
    <form-bean      name="loginForm"
                    type="sis.web.action.LoginForm"/>
 
    <!-- Registration form bean -->
    <form-bean      name="registrationForm"
                    type="sis.web.action.RegistrationForm"/>
 
    <!-- Subscription form bean -->
    <form-bean      name="subscriptionForm"
                    type="sis.web.action.SubscriptionForm"/>
<!--
   <form-bean name="ProductForm"
type="org.cayambe.web.action.ProductActionForm"/>
    <form-bean name="CategoryForm"
type="org.cayambe.web.action.CategoryActionForm"/>
    <form-bean name="CheckOutForm"
type="org.cayambe.web.action.CheckOutActionForm"/>
    <form-bean name="CartForm"
type="org.cayambe.web.action.CartActionForm"/>
  -->
</form-beans>
 
 
 

  <!-- ========== Global Forward Definitions ==============================
-->
  <global-forwards>
    
 
    <!-- for start.jsp page  -->
    <forward   name="home"              path="/doHome.do"/>  
    
    <!-- used when session expired -->
    <forward   name="logon"                path="/doLogin.do"/>
 
    <!-- General forwards, to be changed whenever needed -->
    <forward   name="success"              path="/doHome.do"/>
    <forward   name="failure"              path="/doHome.do"/>
    <forward   name="cancel"              path="/doHome.do"/>
 
    <forward   name="error"              path="/error.jsp"/>
    <!--<forward   name="logon"                path="/index.jsp"/>-->
</global-forwards>
 
  <!-- ========== Action Mapping Definitions ==============================
-->
  <action-mappings>
 
    <!-- Edit user registration -->
    <action    path="/editRegistration"
               type="sis.web.action.EditRegistrationAction"
               name="registrationForm"
              scope="request"
           validate="false">
 
      <forward name="success"              path="/editRegistration.jsp"/>
 
    </action>
 
    <!-- Edit mail subscription -->
    <action    path="/subscribe"
               type="sis.web.action.PrepareSubscriptionAction"
               name="subscriptionForm"
              scope="request"
           validate="false">
 
      <forward name="success"              path="/subscription.jsp"/>
 
    </action>
 
    <!-- Process a user logoff -->
    <action    path="/logoff"
               type="sis.web.action.LogoffAction">
 
    </action>
 
    <!-- Process a user logon -->
    <action    path="/doLogin"
               type="sis.web.action.LoginAction"
               name="loginForm"
              scope="request"
              input="/index.jsp">
 
      <forward name="failure"              path="/index.jsp"/>
 
    </action>
 
    <!-- Save user registration -->
    <action    path="/saveRegistration"
               type="sis.web.action.SaveRegistrationAction"
               name="registrationForm"
              scope="request"
              input="/editRegistration.jsp">
   </action>
 
    <!-- Save subscription FIXME!!! -->
    <action    path="/saveSubscription"
               type="sis.web.action.SaveSubscriptionAction"
               name="subscriptionForm"
              scope="request"
              input="/subscription.jsp">
    </action>
 

    <action    path="/doHome"
               type="sis.web.action.HomeAction"
              scope="request"
           validate="false">
 
      <forward name="failure"              path="/index.jsp"/>
 
    </action>
    
 
    <action    path="/navigate"
               type="sis.web.action.NavigateCategoryAction"
              scope="request"
           validate="false">
      <forward name="failure"              path="/error.do"/>
      <forward name="success"              path="/navigateCategory.jsp"/>
    </action>
 
     <action    path="/gettingstarted"
            forward="/notimplemented.jsp">
    </action>
 <action    path="/servicesearch"
            forward="/notimplemented.jsp">
    </action>

  </action-mappings>
 

</struts-config>

 
Thanks in advance
 
Anat Rozenzon
Telrad Networks
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
 

Reply via email to