Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Apache Struts 2 Architecture in a Nutshell

  1. The web browser requests the pagea resource (/mypage.action, /reports/myreport.pdf, etc)
  2. The Filter Dispatcher looks at the request and determines the appropriate Action<Action
  3. The Interceptors automatically apply common functionality to the request like workflow, validation, and file upload handling
  4. The Action method executes, usually storing and/or retrieving information from a database
  5. The Result renders the output, be it HTML, images, or PDF, to the browser

...

The Struts Tags help you create rich web applications with a minimum of coding. Often, much of the coding effort in a web application goes into the pages. The Struts Tags reduce effort by reducing code.

Code Block
titleBefore Without Struts Tags (a partial form)

<% 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>
...

Looking over the markup, it's easy to see what 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 finish the form using Struts Tags.

...