29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Therefore, an input field declared in a JSP using Java code as:<br />

<br />

can be replaced by a more elegant and efficient Struts tag:<br />

<br />

with no need to explicitly refer to the Java bean from which the initial value is<br />

retrieved. That is handled automatically by the JSP tag, using facilities provided<br />

by the framework.<br />

HTML documents<br />

Although HTML documents generate only static content, you can use standard<br />

HTML documents within your Struts application. Of course, they will not be able<br />

to render any dynamic data, but they are still valid to use whenever the view is<br />

static.<br />

For example, a login page may just be an ordinary HTML document that invokes<br />

a Strut login action.<br />

Struts controller component<br />

The most important Struts controller responsibilities are:<br />

► Intercepting client requests<br />

► Mapping each request to a specific business operation<br />

► Collecting results from the business operation and making them available to<br />

the client<br />

► Determining the view to display to the client based on the current state and<br />

result of the business operation<br />

In the Struts framework, several components are responsible for the controller<br />

duties and they can be classified in two parts: the action servlet and action<br />

classes.<br />

Action servlet<br />

The Struts framework provides the org.apache.struts.action.ActionServlet class<br />

for servlets. The action servlet bundles and routes HTTP requests from the client<br />

(typically a user running a Web browser) to action classes and corresponding<br />

extended objects, deciding what business logic function is to be performed, then<br />

delegates responsibility for producing the next phase of the user interface to an<br />

appropriate view component such as a JSP.<br />

Chapter 12. Using Struts 387

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!