You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by todd thorner <tt...@lycos.com> on 2003/07/31 22:39:44 UTC
Repost: Clicking "Submit" returns a blank page
I have reached this far in my debut 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 (neither "LogonSuccess.jsp" nor "LogonFail.jsp" are blank).
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
Re: Repost: Clicking "Submit" returns a blank page
Posted by Michael Ruppin <mr...@yahoo.com>.
Check that
Constants.SUCCESS=success
m
--- todd thorner <tt...@lycos.com> wrote:
> I have reached this far in my debut 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 (neither "LogonSuccess.jsp" nor
> "LogonFail.jsp" are blank).
>
> 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
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org