教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

基于ASP的网站设计 - 图文(16)

来源:网络收集 时间:2026-04-30
导读: The way an application server invokes a JSP page is different from the way ASP pages are invoked. A J2EE application server converts each JSP page into a separate special servlet that compiles and ru

The way an application server invokes a JSP page is different from the way ASP pages are invoked. A J2EE application server converts each JSP page into a separate special servlet that compiles and runs when the page is requested. The special servlet remains loaded in memory until the JSP file changes. This minimizes the performance hit that might result if you had to create and compile a class for each JSP page.

Model-View-Controller architecture

J2EE was developed with a particular application structure in mind, called Model-View-Controller (MVC). MVC defines a clear separation among three

48

tiers of an application:

The model: The set of data and business rules for the application --

commonly called the application's business logic

The view: The application's user interface

The controller: Definition of the way the application reacts to user input

or to changes in the model tier -- commonly called application logic

Advantages of a MVC architecture

Nothing in J2EE forces you to structure your applications with a MVC architecture, but there are good reasons to do so. By defining a clear separation among the three tiers, MVC allows for loose coupling among the components that comprise each tier. This makes the components more reusable and flexible. For example, suppose one of your requirements is to support different types of views of the same data in a Web application, because different departments need different subsets of the same data in a database. You need to develop new view components specific to each required subset. If the view logic and database-access code were tightly coupled -- as they are an ASP page that interleaves database-access code with HTML -- then each view would contain the database-access code. Maintaining duplicate code not only takes a lot of work, but it's likely to lead to errors. A MVC architecture in this scenario uses the database-access code as part of the model, and the various view components can reuse it.

49

J2EE components and MVC

Figure 1 shows how the J2EE components we've discussed so far could map to a MVC architecture. Note that no connection exists between the model and the view. The controller's function is to serve as a conduit between the two.

Figure 1. MVC with J2EE Web applications

In a typical scenario, the user submits an HTML form whose target is a servlet. The servlet parses the input and uses classes in the model to invoke the business logic to satisfy the request. The servlet then passes the results to a JSP page to display them to the user.

JavaServer Faces

The JavaServer Faces (JSF) specification provides the runtime components that let J2EE tool vendors provide drag-and-drop capability for the development of Web-based UIs. It also lets vendors develop custom components their development tools can use. To see JSF in action, take a look at the WebSphere

50

…… 此处隐藏:859字,全部文档内容请下载后查看。喜欢就下载吧 ……
基于ASP的网站设计 - 图文(16).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/598877.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)