struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "todd thorner" <tthor...@lycos.com>
Subject Logon "Submit" returns a blank page
Date Mon, 28 Jul 2003 10:56:37 GMT
Hi and thanks,

Ok, I have reached this far in my logon page development...

The first JSP page comes up fine, showing me a form <html:form action="/LogonSubmit">
with a rendered <html:text> tag for each required field (username and password), plus
a "Reset" and a "Submit" button.  Code sample below comes from my struts-config.xml file:

<form-beans>
 <form-bean name="logonForm" type="mystrutsforms.LogonForm"/>
</form-beans>

<global-forwards>
 <forward name="logon" path="/Logon.do"/>
</global-forward>

<action-mappings>
 <action path="/Logon" type="org.apache.struts.actions.ForwardAction" parameter="/pages/Logon.jsp"/>
 <action path="/LogonSubmit" type="mystrutsactions.LogonAction" name="logonForm" scope="request"
validate="true" input="/pages/Logon.jsp">
   <forward name="success" path="/pages/LogonSuccess.jsp"/>
   <forward name="fail" path="/pages/LogonFail.jsp"/>
  </action>
</action-mappings>

****************** struts-config.xml code above ******************

I can enter data into the <html:text> fields and they will erase if I click "Reset"
I can click "Submit" with nothing filled in (passing nulls with the request), and the proper
<html:errors/> are displayed
However,

If I enter any values for the "username" and "password" fields, then click "Submit," a blank
page is always returned.

What's up with that?  The browser says it's trying to display results from "LogonSubmit.do"
(which is what I expect).  I have a file called "users.properties" in the directory "WEB-INF/classes"
and in my LogonAction.java code:

public final class LogonAction extends Action {

    public ActionForward execute( ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response )
        throws Exception {

        String username = ( ( LogonForm ) form ).getUsername();
        String password = ( ( LogonForm ) form ).getPassword();
        boolean validated = false;
	
        try {

            validated = isUserLoggedOn( username, password );
        }
        catch ( SimpleUserDirectoryException sudexc ) {
            ActionErrors errors = new ActionErrors();
            errors.add( ActionErrors.GLOBAL_ERROR,
            new ActionError( "error.logon.connect" ) );
            saveErrors( request, errors );
            return ( new ActionForward( mapping.getInput() ) );
        }

        if ( !validated ) {

            ActionErrors errors = new ActionErrors();
            errors.add( ActionErrors.GLOBAL_ERROR,
            new ActionError( "error.logon.invalid" ) );
            saveErrors( request, errors );
            return ( new ActionForward( mapping.getInput() ) );
        }

        HttpSession session = request.getSession();
        session.setAttribute( Constants.USER_KEY, form );
	
        return ( mapping.findForward( Constants.SUCCESS ) );
    }

    public boolean isUserLoggedOn( String username,
        String password ) throws SimpleUserDirectoryException {

        return ( SimpleUserDirectory.getInstance().passwordIsValid( username, password ) );
    }    
}

****************** mystrutsactions.LogonAction.java code above ******************

Note: The LogonAction.java file above makes use of the following SimpleUserDirectory.java
code:

	private static final String SimpleUserDirectoryFilepath = "users.properties";
	InputStream ips = this.getClass().getClassLoader().getResourceAsStream( SimpleUserDirectoryFilepath
);
	
****************** mystrutsforms.LogonForm.java code above ******************

Also, my web.xml file has:

<init-param>
 <param-name>application</param-name>
 <param-value>application</param-value>
</init-param>

****************** web.xml code above ******************

Any suggestions or guesses are appreciated.


____________________________________________________________
Get advanced SPAM filtering on Webmail or POP Mail ... Get Lycos Mail!
http://login.mail.lycos.com/r/referral?aid=27005

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message