Look for an exception in the logs. Empty output usually means an uncaught exception.

--David

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.

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>


----------------------------------------------------------------------------
----

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);
       }

       LogonForm logonForm = (LogonForm)form;
       log.debug("username "+logonForm.getUsername());
       log.debug("password "+logonForm.getPassword());

       return mapping.findForward(Constants.SUCCESS);
   }


----------------------------------------------------------------------------
----

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"));
       }
       if
(FormUtils.isNullOrEmpty(httpServletRequest.getParameter("password"))) {
           log.debug("logon.form.password.invalid");
           errors.add(ActionErrors.GLOBAL_MESSAGE,new
ActionMessage("logon.form.password.invalid"));
       }

       return errors.isEmpty() ? null : errors;
   }


----------------------------------------------------------------------------
----

Two tags of interest from struts-config.xml -

      <!-- Process a user logon -->
      <action   path="/SubmitLogonForm"
                type="template.action.LogonAction"
                name="LogonForm"
                scope="request"
                input="/logon.jsp">
         <forward name="success" path="/welcome.jsp" />
      </action>



   <!-- Logon form -->
   <form-bean name="LogonForm" type="template.form.LogonForm"/>

----------------------------------------------------------------------------
----

ApplicationResources.properties - Note this is found and read by Tomcat, I
can
pull values from it using bean:message - the errors.head and prefix are not
displayed however, so clearly no error messages are being generated at all.

index.heading=Index Page Heading
index.logon=Logon
index.register=New User
#
struts.logo.path=/struts-power.gif
struts.logo.alt=Powered by Struts
# form fields
logon.form.username.invalid=Username invalid
logon.form.password.invalid=Password invalid
# page titles
error.title=Error Title
logoff.title=Logoff Title
logon.title=Logon Title
register.title=Register Title
welcome.title=Welcome Title
#
errors.header=Errors
errors.prefix=Error prefix

----------------------------------------------------------------------------
----


Well it's 2AM here in London, so here's hoping for an answer when I get up
later
today !

TIA,

Andy.



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



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

Reply via email to