You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Mattos <Jo...@Mattos.ws> on 2004/09/20 06:50:04 UTC

Basic Action Question (I need more sets of eyes)

Hi

 

I've been staring at this for a while and I can't see what's wrong. Maybe
one of you can help me out. I'm trying to create a basic login form. 

 

The form validation part is working (comes back and tells me that uid or pw
has to be entered if I neglected to) but it SEEMS that the
LoginAction.execute() is not getting called. 

 

When I click "login" with username and password filled out, I get sent to a
blank screen with minimal html.

 

Help!!!! Could it be a problem with my deployment? Am I missing something
else? Note that I do in fact have "success.jsp" and "error.jsp" in a
subdirectory "/pages"

 

Here are the parts that seem to not be working.

 

This should be a really simple thing, no? I'd even send my WAR file to get
some help at this point..

 

// ***** Action Class ****

package com.blah.login;

 

import javax.servlet.http.*;

import org.apache.struts.action.*;

 

public final class LoginAction extends Action

{

            public ActionForward perform(ActionMapping mapping, ActionForm
form,

                                    HttpServletRequest request,
HttpServletResponse response){

                        System.out.println("Text that is never seen");

                        LoginForm f = (LoginForm) form;

                        String userName=f.getUserName();

                        String password = f.getPassword();

                        

                        // Will implement real PW checking when this is
working :-(

                        if(userName.equals("admin") &&
password.equals("admin123")){

                            return (mapping.findForward("success"));

                        }else{

                            return (mapping.findForward("failure"));

                        }

            }

}

 

// <!-Login.jsp -->

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

 

<html>

<head><title>Yale New Haven Health Services</title></head>

<body>

<h3>YNHHS Login Page</h3>

<html:errors/> 

 

<html:form action="login.do"> 

      User Name:<html:text property="userName"/><br>

      Password:<html:password property="password"/><br>

      <html:submit/>

</html:form>

 

</body>

</html>

 

// ********************************Struts Config.xml
*************************

<!-- ====================================== Form Bean Definitions -->

   <form-beans>

        <form-bean name="loginForm" 

type="com.ynhhs.login.LoginForm"/>

   </form-beans>

 

<!-- ================================ Action Mapping Definitions -->

    <action-mappings> 

          <!--Action  Mappings for Login-->

          <action   

                  path="/login"

              type="com.ynhhs.login.LoginAction"

              name="loginForm"

              scope="request"

              input="/login.jsp">

            <forward name="success" path="/pages/success.jsp"/>

            <forward name="failure" path="/pages/error.jsp"/>

          </action>

    </action-mappings>

 

// The weird nothing HTML page I end up at after loggin in

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD>

<META http-equiv=Content-Type content="text/html;
charset=windows-1252"></HEAD>

<BODY></BODY></HTML>