trim().length() < 3) ||
(email.indexOf("@") == -1)) {
return(mapping.findForward("bad-address"));
} else if ((password == null) ||
(password.trim().length() < 6)) {
return(mapping.findForward("bad-password"));
} else {
return(mapping.findForward("success"));
}
}
}
Chapter 10 ?– The Struts Framework: Basics 498
Step 5: Create a Form That Invokes blah.do
For this example, we need an input form that invokes http://hostname/struts-beans/
register.do. This form is given in Listing 10.18.
Step 6: Display the Results in a JSP Page
We have three possible output pages, depending on the input provided by the user.
All three output pages rely on beans in the request scope.
To display the bean properties, we use the Struts bean:write tag. To use this
tag, however, we have to import the bean tag library in our JSP pages as follows:
<%@ taglib uri="http://struts.apache.org/tags-bean"
prefix="bean" %>
Here is a summary of the three output pages.
??? bad-address3.jsp. This page is displayed if the user did not provide a
legal e-mail address. We use bean:write to display the bad e-mail
address from the form bean and to display a suggested e-mail address
from the suggestion bean. See bad-address.jsp in Listing 10.19.
??? bad-password.jsp. This page is displayed if the user did not provide a
legal password. Again, we use bean:write to display the bad password
from the form bean and to display a suggested password from the
suggestion bean.
Pages:
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553