RSS

Monthly Archives: May 2013

The Six Basic Steps in Using Struts

The Six Basic Steps in Using Struts
There are six basics steps needed to implement the control flow just described.

1. Modify struts-config.xml. For basic Struts usage, this file should
contain three main sections: a table that maps incoming addresses to
Action objects (action entries), a table that maps return conditions
to JSP pages (forward entries), and a list of the beans used to handle
request parameters (form-bean entries).

2. Define a form bean. Rather than requiring you to call
request.getParameter for each incoming piece of query data,
Struts can instantiate and populate a bean representing the incoming
form data. This is one of the single most useful features of the Struts
framework.

3. Create the results beans. If the JSP page needs data resulting from
the business logic, then create results beans to hold the data. These
beans are nothing Struts-specific, but are normal beans as used in the
basic MVC architecture.

4. Define an Action class to handle the request. Struts automatically
invokes the execute method of the Action object specified in
the action entry of struts-config.xml. The execute method typically
uses the form bean to access request data submitted by the user,
invokes business logic and data-access logic, stores results beans based
on that logic, and calls mapping.findForward to designate the
result condition.

5. Create a form that invokes blah.do. Create an HTML form for the
user’s input. Use html:form to associate the form with a bean and to
specify the address that should handle the form submission. Use
html:text and related elements to gather user data and to associate
bean properties with the input elements.

6. Display the results in a JSP page. Write a JSP page to display the
results. Depending on the user input and business logic, you could
have more than one possible results page. Use bean:write or the
JSP EL to output bean properties.

 
Leave a comment

Posted by on May 22, 2013 in Material

 

Struts Flow of Control

Struts Flow of Control

Before writing your first Struts application, you need to understand the normal flow of execution through the Struts framework. Figure illustrates the apparent execution flow of the request through the Struts framework. We use the word apparent because, behind the scenes, the Struts system handles numerous internal steps.
The following list summarizes the flow
1. The user requests a form. The input form is built with the Struts html: tags. These tags associate a bean with the form so that you can prepopulate the form with values from your application, so that you can redisplay incorrectly filled out forms, and so that Struts knows
where to store the request parameters when the form is submitted.
2. The form is submitted to a URL of the form blah.do. The form contains an ACTION ending in blah.do. The Struts system receives the request, where an action mapping in struts-config.xml associates the address with an Action object.
3. The execute method of the Action object is invoked. One of the arguments to execute is a form bean that is automatically created and whose properties are automatically populated with the incoming form data. Once it examines the user input data in the bean,
the execute method invokes business logic and data-access logic, placing the results in normal beans stored in the request, session, or application scope. Finally, the execute method uses mapping. findForward to return various conditions that are mapped by struts-config.xml to JSP pages.
4. Struts forwards the request to the appropriate JSP page. Struts normally invokes the results page with RequestDispatcher.forward, although request.sendRedirect is occasionally used (e.g., with session-scoped data). In most real applications, the results page uses bean:write or the JSP 2.0 EL to output bean properties.

struts

Figure – Struts flow of control

 
Leave a comment

Posted by on May 22, 2013 in Material

 

Question Bank of WTAD

Question Bank of wtad Download

 
Leave a comment

Posted by on May 7, 2013 in Material