John,

When I was first learning Struts, I saw that kind of page when I had an
incorrect action method.  I use execute() and there are two performs.  One
with this ServletRequest and ServletResponse while the other has
HttpServletRequest and HttpServletResponse.  Have you tried using execute()
in place of perform?  And how old is the version of Struts that you are
using perform?  I thought it was deprecated in 1.1 and removed in 1.2.X.  I
ask this since you sound like you are learning struts and if so, perform()
isn't the way to go, execute() is.

Are you making a 'perform()' in 1.2.X and you're getting a blank screen
because the action now calls execute(), not perform()?

Additionally, is your perform() even being called?  Do you see your echo
print "Text that is never seen" in your log file?

Regards,
David


-----Original Message-----
From: John Mattos [mailto:[EMAIL PROTECTED]
Sent: Monday, September 20, 2004 1:10 AM
To: [EMAIL PROTECTED]
Subject: 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.perform() 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?



// ***** 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> </title></head>

<body>

<h3>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.blah.login.LoginForm"/>

   </form-beans>



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

    <action-mappings>

          <!--Action  Mappings for Login-->

          <action

                  path="/login"

              type="com.blah.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>



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

Reply via email to