Now that we have covered the better portion of material on how to useJ SP to build dynamic web pages, we will look at how we can construct complete web applica- tions with this technology. In this chapter we will discuss several architectural mod- els useful for developingJ S P applications. We will examine architectural options available to us when we combineJS P pages with servlets,E JBs,H TM L, and other software elements to create web-based applications.
The three layers (figure 10.1) aren\u2019t necessarily separate software elements or com- ponents (though as we shall see they can be), but rather they are useful constructs to help us understand our application\u2019s requirements. If you are familiar with design patterns, a collection of common strategies used in software development, you might recognize this three-part architecture as an implementation of the Model- View-Controller, orMV C, pattern. The M VC pattern is concerned with separating the information (the model) from its presentation (the view), which maps nicely into our strategy.
Each layer plays an important role in an applica- tion\u2019s architecture and will be discussed briefly in the sections which follow. It is often advantageous to treat each tier as an independent
portion of your application. Isolating the logical portions of the application helps ensure that you\u2019ve covered all the bases in the design, focuses attention on creating a robust architecture, and lays the groundwork for the implementation.
This tier includes the client-side display elements, such asH T M L,X M L, or Java applets. The presentation layout tier can be thought of as the user interface for the application because it is used to get input from the end user and display the applica- tion\u2019s results. In theMV C paradigm, the presentation layout tier fills the role of the view. It is an application specific presentation of the information owned by the application logic, or model inM VC terms.
The presentation layout tier is not concerned with how the information was obtained, or from where. Its responsibilities lie only in displaying the information itself, while delegating any other activity up the chain to other tiers. For example, in an application which involves submitting a search query through a web form only the form itself and the corresponding results are the responsibility of the presenta- tion layer. What happens in between, the processing of the request and the retrieval of the results, is not.
The application logic layer is the heart of the application, responsible for actually doing whatever it is the application is supposed to do. It is responsible for perform- ing queries against a database, calculating sales tax, or processing orders. This layer models the data and behavior behind the business process for which we are devel- oping the application. It is an encapsulation of data and behavior that is indepen- dent of its presentation.
Unlike the presentation layer, this tier cares only about storing, manipulating, and generating data, not displaying it. For this reason, components designed to work as application logic can be relocated outside web-based applications, since the behavior they encapsulate isn\u2019t web-centric.
The control layer determines the application\u2019s flow, serving as an intermediary between the presentation layer and the application logic. This tier serves as the log- ical connection between the user\u2019s interaction with the front-end and business services on the back end. In theMV C pattern this tier is acting as the controller. It delivers the model to the view and regulates communication between the two.
Now bringing you back...
Does that email address look wrong? Try again with a different email.
This action might not be possible to undo. Are you sure you want to continue?