Struts

The Struts2.0 View: -JSP Pages & Presentation Components
adplus-dvertising
Previous Home Next

Introduction:

The view is the presentation component of the MVC pattern. we see that the result returns the page to the web browser. This page is represent the user interface application’s state. These are commonly JSP pages, Velocity templates, or some other presentation-layer technology .While there are many choices for the view, the role of the view is clear-cut: it translates the state of the application into a visual presentation with which the user can interact .With rich clients and Ajax applications increasingly complicating the details of the view, it becomes even more important to have clean MVC separation of concerns. Good MVC lays the groundwork for easily managing the most complex front end.

lass/Library File Descriptions:

Struts HTML/JSP View layer support can be broken down into the following major components:-

  • JSP page
  • Form Beans
  • JSP tag libraries
includes Struts2 in an extensive custom tag library that facilitates creating user interfaces that are fully internationalized. These are

  1. The HTML Tag Library.
  2. The Bean Tag Library.
  3. The Logic Tag Library.
  4. The Nested Tag Library. >>Resource bundles

Source Code:

index.jsp
<action name="HelloWorld" 
class="manning.chapterOne.HelloWorld">
<result name="SUCCESS">/chapterTwo/HelloWorld.jsp
</result>
<result name="ERROR">/chapterTwo/Error.jsp
</result>
</action>
<%@ taglib uri="/struts-tags" prefix="s"%>
<table cellpadding="0" cellspacing="0">
    <tr>
    <td height="300" width="300" 
	style="background-image: url('images/2.JPG')
	;color: yellow;" align="center">
    <h1 style="color: yellow;">Login Page</h1>
<s:actionerror/>
<s:form action="login" cssStyle="color:yellow;">
<s:textfield name="name" label="Name"/>
<s:password name="password" label="Password"/>
<s:submit value="Login"/>
</s:form>
</td>
  </tr>
</table>
Previous Home Next