Only available on StudyMode
  • Topic: JavaServer Pages, Java, Java Servlet
  • Pages : 9 (2246 words )
  • Download(s) : 269
  • Published : November 16, 2010
Open Document
Text Preview
Tutorial: Building a Web Application with Struts
This tutorial describes how OTN developers built a Web application for shop owners and customers of the Virtual Shopping Mall (VSM) sample application. OTN developers used Oracle9i JDeveloper and the Jakarta Project's Struts framework to build the application.

1. Concepts 2. Design 3. Required Software 4. Setup 5. Implementation 6. Resources 7. Feedback


The Jakarta Project's Struts framework, version 1.1b2, from Apache Software Organization is an open source framework for building web applications that integrate with standard technologies, such as Java Servlets, JavaBeans, and JavaServer Pages. Struts offers many benefits to the web application developer, including Model 2 implementation of Model-View-Controller (MVC) design patterns in JSP web applications. The MVC Model 2 paradigm applied to web applications lets you separate display code (for example, HTML and tag libraries) from flow control logic (action classes). Following is a brief overview of the MVC Model 2 design pattern. For complete information about how Struts implements the MVC design patterns, see the Introduction to the Struts User's Guide on the Jakarta Project's Web site: q

The Model portion of an MVC-based system typically comprises JavaBean classes that define the internal state of the system; they also specify the actions that can be taken to change that state. If you use the BC4J data access framework, this layer implements the model entirely for you. Otherwise, you will need to create the classes that implement your model. The View portion of a Struts-based application is generally constructed using JSP technology. JSP pages can contain static HTML (or XML) text called "template text", plus the ability to insert dynamic content based on the interpretation (at page request time) of special action tags. The JSP environment includes a set of custom JSP tag libraries (such as the Struts tag libraries), standard JSP action tags (such as those described in the JavaServer Pages Specification), and a facility to install your own JSP custom tag libraries. If you use the BC4J data access framework, you can take advantage of JDeveloper's JSP generation wizards and the custom tag libraries that allow your JSP pages to display databound dynamic content.



The Controller portion of the application is focused on receiving requests from the client (typically a user running a web browser), deciding what business logic function is to be performed, and then delegating responsibility for producing the next phase of the user interface to an appropriate View component. In Struts, the primary components of the Controller is a servlet of class ActionServlet and the class RequestProcessor. If you use the BC4J data access framework, the RequestProcessor is extended for you and is known as the BC4JRequestProcessor.

JDeveloper helps you implement the MVC Model 2 design patterns using core technology familiar to all web developers: q

You can create JSP pages with HTML and custom tag libraries to implement the View of the data. You use links to let the user trigger actions on the HTTP Request. You can enhance your JSP pages using a large set of custom JSP tag libraries that work with the Struts framework. All of the Struts tag libraries are accessible from the JDeveloper Component Palette, when you open a JSP in the Code Editor. For example, the Struts Form tag works closely with the Struts actions and form bean to retain the state of a data-entry form and validate entered data. Unlike non-Struts JSPs, when you run your application, action requests do not invoke another JSP or Servlet directly. Instead, the request URI specifies a logical page request, which the request processor (RequestProcessor class) provided by the Struts controller handles. The Struts servlet may direct the responsibility for displaying the action results...
tracking img