Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Blank page returned from ActionForm  RSS feed

Andy Lucian
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I'm an experienced Java programmer new to Struts. I have to say so far I'm finding it very frustrating.

My problem is that I get a blank page returned from an ActionForm derived class when I click the associated form's submit button, and secondly that no errors are displayed by the <html:errors/> tag. I have hardcoded an error message in validate, but it isn't displayed.

I *know* validate is called because when I click the form's cancel button, Tomcat correctly finds and performs the forward to an error page - this behaviour is just for testing. Ohh and as if that wasn't enough can't seem to get Log4j to log, but that's secondary for now.

I'm sure this is probably just a case of not having read enough documentation...

From struts-config.xml (relevant tags only) :

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

<!-- Process a user logon -->
<action path="/SubmitLogonForm"
<forward name="failure" path="/error.jsp" />
<forward name="success" path="/welcome.jsp" />

Class template.form.LogonForm :

public class LogonForm extends ActionForm {

private String username;
private String password;

public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;

public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
// initial values of form fields
username = null;
password = null;
public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {

ActionErrors errors = new ActionErrors();
errors.add("password",new ActionMessage("logon.form.password.invalid")); // TESTING ONLY
// validate on submit
if (FormUtils.isNullOrEmpty(httpServletRequest.getParameter("username"))) {
errors.add("ERRORS",new ActionMessage("logon.form.username.invalid"));
if (FormUtils.isNullOrEmpty(httpServletRequest.getParameter("password"))) {
errors.add("ERRORS",new ActionMessage("logon.form.password.invalid"));

return errors;

JSP logon.jsp :

<html:form action="/SubmitLogonForm">
<td><html:text property="username"/></td>
<td><html:text property="password"/></td>
<html:submit/> <html:cancel/>

From Action derived class :

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

Thanks for any ideas ...

alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you get a blank page, it means the target is not found (Constants.SUCCESS) in the action-mapping forward. double check your Constants.SUCCESS value. do a println.out of the Constants.SUCCESS in your .execute() before return findForward. you need to resolve the target issue first before addressing the errors not being printed out.

you need to add validate="true" to your action mapping. this tells the struts to validate the form. also, if you are adding error messages inside your action, you need to call saveMessages(request,messages); before returning the forward.

also, what version of struts are you using? ActionErrors are deprecated in 1.2.x. you may want to look at the declarative validation (based on XML file) instead of using the old struts 1.0 validate(). also, instead of creating beans, try configure the bean using form-bean definitions. i suggested these because you are just starting out. it's best to stay away from deprecated features and 'way of programming'.
[ May 25, 2005: Message edited by: alan do ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!