...
Code Block | ||
---|---|---|
| ||
<% User user = ActionContext...getContext() %> <form action="Profile_update.action" method="post"> <table> <tr> <td align="right"><label>First name:</label></td> <td><input type="text" name="user.firstname" value="<%=user.getFirstname() %> /></td> </tr> <tr> <td><input type="radio" name="user.gender" value="0" id="user.gender0" <% if (user.getGender()==0) { %> checked="checked" %> } %> /> <label for="user.gender0">Female</label> </tr> </table> </form> ... |
Looking over the markup, it's easy to see why Java web development without the aid from a modern framework is hard! So far, we've only coded two controls, and there are six more to go! Let's rewrite and finish the form using Struts Tags.
|
|
...
Here's a typical configuration (struts.xml
) for a login workflow:
Code Block | ||||
---|---|---|---|---|
| ||||
<struts> <package name="default" extends="struts-default"> <action name="Logon" class="mailreader2.Logon"> <result name="input">/pages/Logon.jsp</result> <result name="cancel" type="redirect-actionredirectAction">Welcome</result> <result type="redirect-actionredirectAction">MainMenu</result> <result name="expired" type="chain">ChangePassword</result> </action> <action name="Logoff" class="mailreader2.Logoff"> <result type="redirect-actionredirectAction">Welcome</result> </action> </package> </struts> |
The framework provides general-purpose defaults, so we can start using Struts right away, "out of the box". Any factory defaults can be overridden in an application's configuration, as needed.
...