Shared Flashcard Set

Details

Struts 1.x
Study cards for the struts framework, its various xml tags, etc.
9
Computer Science
Professional
01/30/2010

Additional Computer Science Flashcards

 


 

Cards

Term
Strust was developed by
Definition
Craig R McClanahan
Term
Elements of Struts
Definition
  • Action Servlet
  • struts-config.xml
  • Action Mapping (defined in struts-config.xml )
  • Action
  • ActionForm
  • ActionForward
  • ActionMessages
Term
ActionServlet
Definition
  1. org.apache.struts.action.ActionServlet
  2. acts as the FrontController or Controller (in MVC)
  3. sends the request to a component in the web container based on action mappings defined in the struts-config.xml
  4. Standard J2EE Servlet
  5. Starts the flow of control defined in the RequestProcessor.
  6. Overrides doGet and doPost methods to call process method
  7. Specified in web.xml like any other servlet: 

<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet

 

<servlet-mapping>

 <servlet-name>action</servlet-name>

<url-pattern>*.do</url-pattern>

Term
Request/Response round trip
Definition

1. Browser sends request – passed to J2EE server
2. Web Container of J2EE server invokes ActionServlet
3. ActionServlet finds an ActionMapping for request
4. ActionMapping indicates which Action to invoke
5. Action works with ActionForm
6. Action calls business objects as needed
7. Action returns an ActionForward to the ActionServlet
– Forward is usually to a JSP view that is presented to a user

Term
ActionMapping
Definition

<action-mappings>
  <action path="/logon"
              type="stocktraderweb.actions.LogonAction"
              name="logonForm"
              scope="request"
              validate="false">
    <forward name="success" path="./welcome.jsp"/>
    <forward name="unauthorized"
path="./unauthorized.jsp"/>
  </action>

</action-mappings>

Term
RequestProcessor
Definition
  1. Not a Servlet.
  2. Parses URI and determines requested action.
  3. Maps params to ActionForm (form bean)
  4. Calls appropriate Action's execute method.
  5. OR Calls appropriate ActionForward to pass off control flow.
Term
ActionForm
Definition
  • aka FormBean
  • Form encapsulated as an object
  • uses Java bean conventions
  • it can also provide validation code by overriding the validate() method.
Term
Actions
Definition
  • Should control flow - NOT logic.
  • Wrapper around business logic.
  • Business logic s/b in model layer, not action.
  • Sometimes described as Adapters - they provide the necessary interface to the Model layer.
Term
Predefined Struts Actions
Definition

Predefined Ations in Struts:

  1. DispatchAction
  2. LookupDispatchAction
  3. ForwardAction
  4. IncludeAction
  5. SwitchAction
Supporting users have an ad free experience!