tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy" <a...@fritter.net>
Subject RE: <html:errors/> blank page on invalid form
Date Thu, 26 May 2005 16:00:30 GMT

Guru and Nikola,

Thanks for the suggestions, having looked at this again, I think this is a
Struts problem however, so I've posted to struts-users.

Thanks anyway,

Andy.

>-----Original Message-----
>From: Gurumoorthy [mailto:g.raghupathy@btinternet.com]
>Sent: 26 May 2005 08:37
>To: Tomcat Users List
>Subject: Re: <html:errors/> blank page on invalid form
>
>
>hello
>        <html:form action="/SubmitLogonForm.do"> is wrong
>        <html:form action="/SubmitLogonForm">
>
>Regards
>Guru
>
>----- Original Message -----
>From: "Nikola Milutinovic" <Nikola.Milutinovic@ev.co.yu>
>To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>
>Sent: Thursday, May 26, 2005 6:04 AM
>Subject: Re: <html:errors/> blank page on invalid form
>
>
>> Andy wrote:
>>
>> >Hi All,
>> >
>> >I'm unable to output any errors using <html:errors/> tag, in Tomcat
>> >5.5.7 I've tried numerous configurations and have now ran out of
>patience.
>> >As I haven't been using Struts for more than three days I hope somebody
>> >more experienced can point help me out.
>> >
>> >When I select Submit, entering data into my form fields so the form is
>> >parsed as valid, the forward works correctly. When I leave the fields
>> >empty, so the form is parsed as invalid, I just get an empty page back -
>> >which must be generated by Struts as it doesn't match any HTML I have.
>> >
>> >
>>
>> Check out the logs, you could be running into an exception. Also, set
>> buffer size of 20kb on all your pages, while you're testing. Empty
>> output can also be caused by an exception in the page itself, and buffer
>> being already sent.
>>
>> >Here is what I have in various files -
>> >
>>
>>------------------------------------------------------------------
>---------
>-
>> >----
>> >
>> >logon.jsp -
>> >
>> ><%@ page contentType="text/html;charset=UTF-8" language="java" %>
>> ><%@ taglib uri="/tags/struts-bean" prefix="bean" %>
>> ><%@ taglib uri="/tags/struts-html" prefix="html" %>
>> ><html>
>> ><head>
>> ><title><bean:message key="logon.title"/></title>
>> ></head>
>> ><body>
>> ><html:errors/>
>> ><html:form action="/SubmitLogonForm.do">
>> >    <table>
>> >    <tr>
>> >        <td>Username</td>
>> >        <td><html:text property="username"/></td>
>> >    </tr>
>> >    <tr>
>> >        <td>Password</td>
>> >        <td><html:text property="password"/></td>
>> >    </tr>
>> >    <tr>
>> >        <td>
>> >        <html:submit/>
>> >        <html:cancel/>
>> >        </td>
>> >        <td></td>
>> >    </tr>
>> >    </table>
>> ></html:form>
>> >
>> ></body>
>> >
>> >
>>
>> Looks fine, except for the buffer page directive.
>>
>> >In LogonAction.java -
>> >
>> >
>> >    public ActionForward execute(ActionMapping mapping, ActionForm form,
>> >                                 HttpServletRequest request,
>> >HttpServletResponse response)
>> >                                throws Exception {
>> >
>> >        if (isCancelled(request)) {
>> >            log.debug("cancel pressed");
>> >            return mapping.findForward(Constants.FAILURE);
>> >        }
>> >
>> >
>>
>> Why would you consider "Cancel" a failure? Not that it will not work,
>but...
>>
>> >        LogonForm logonForm = (LogonForm)form;
>> >        log.debug("username "+logonForm.getUsername());
>> >        log.debug("password "+logonForm.getPassword());
>> >
>> >        return mapping.findForward(Constants.SUCCESS);
>> >    }
>> >
>> >
>>
>> You're not checking the login, but that's fine for a test.
>>
>> >In LogonForm.java (I have getters/setters for HTML fields, and a reset
>> >method,
>> >not shown) -
>> >
>> >    public ActionErrors validate(ActionMapping actionMapping,
>> >HttpServletRequest httpServletRequest) {
>> >
>> >        log.debug("validate");
>> >        ActionErrors errors = new ActionErrors();
>> >
>> >        if
>> >(FormUtils.isNullOrEmpty(httpServletRequest.getParameter("username"))) {
>> >            log.debug("logon.form.username.invalid");
>> >            errors.add(ActionErrors.GLOBAL_MESSAGE,new
>> >ActionMessage("logon.form.username.invalid"));
>> >        }
>> >
>> >
>>
>> You don't need to use GLOBAL_MESSAGE, that is wrong, I think. And use
>> errors, not messages. My validation would read:
>>
>> errors.add( "username", new ActionError( "logon.form.username.invalid"));
>>
>> Nix.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



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


Mime
View raw message