- 浏览: 214787 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
a66756675:
...
tomcat:tomcat的OutOfMemoryError解决 -
ooo456mmm:
说的对,如果用Mina框架来处理,要简单很多了
NIO socket服务器注意的几点. -
long_ltoy:
这样的话,看上去是代替了session,但这不和session ...
在JSP中使用JAVABEAN代替Session -
linzx0212:
关注下,不错……
tomcat:tomcat的OutOfMemoryError解决 -
liudeh_009:
总结得很好
NIO socket服务器注意的几点.
JSP Design Notes
White Paper Sections
Introduction to JSP Design Notes
Java Server Pages (JSP's) permit server side Java logic to reside within the requested document. Upon request of a JSP document the server activates the specified JSP. The JSP then becomes responsible for providing an HTML response.
The server side logic within a JSP is written in Java. The Java code segments, referred to as scriptlets, are generally responsible for providing dynamic HTML content to the JSP's response HTML. The JSP itself is compiled by the server, and is executed as an object that extends the Java Servlet API. As such, the HTTP Servlet request and response objects are available by the scriptlets defined within the JSP.
This document reviews client-server design considerations in respect to the use of JSP抯. Implementation options, particularly the use of JSP language extensions and use of Enterprise Java Beans (EJB's) will also be discussed. Focus will be placed on the presentation layer and how the JSP is used to provide a user interface and communicate business logic requests to the supporting system.
If we consider a 3-tier architectural WEB application, the browser becomes the client side application. The user communicates requests to the WEB/app server via the browser. The presentation layer receives the client requests and prepares the response and server side business functionality is executed. In the context of this example, the JSP engine represents the presentation layer. It is responsible for processing requests and responses. Additional messages may be passed between this layer and that which handles business processes represented below as EJB抯.
The Technology
JSP technology uses XML - like tags and scriptlets. They are used to encapsulate presentation logic within the JSP. They can also initiate messages to distributed or server-side applications. The logical separation of presentation and business logic lies in the implementation of the JSP.
Enterprise Java Beans provide a distinct relationship between the implementation of business logic and the remote interfaces provided to the EJB client. The use of an EJB typically follows the pattern:
- The client application identifies itself to the server
- The client application uses the Java Naming Directory service to locate the desired EJB
- The client application retrieves a handle to the EJB Home and subsequently Remote interfaces.
The remote interface contains methods that the client is permitted to use. They represent a summary of the business logic that is implemented by the bean. The implementation logic is defined within the primary bean class. All IPC, database and resource details are restricted to the bean class.
Prevalent Application
Design constraints and conventions maintain the separation of presentation logic from business logic in the middle tier. Prior to JSP 1.1, a JSP implementation using EJB's might have included various scriptlet sections performing EJB remote interface logic/communication.
Consider the example below:
The JSP is designed to provide a welcome message to an e-commerce user. Assume the request included an HTML name-value pair that identified the (pre-registered) Customer ID.
<html> <title>E-commerce Site</title> <body> <% String CustomerName; String CustomerCompany; String customerID; customerID = (String) pageContext.getRequest().getParameter("CustID"); Context ctx = getContext("some.ejb.jndi.name"); EJBHome home = (EJBHome)ctx.createHomeInterface(); EJBRemote remote = (EJBRemote)home.findCustomer(customerID); CustomerName = remote.getCustomerName(); CustomerCompany = remote.getCustomerCompany(); %> Welcome <%=CustomerName%> we look forward to processing your needs. <br> <%=CustomerCompany%> is one of our favorite companies to work with. </body> </html> |
The resulting JSP is a hybrid of scripting logic and html. In constructing a JSP document, the creation of the HTML base is a prudent step. It becomes the visual template that JSP scriptlets are merged into. The post execution HTML produced from the completed JSP should be that of the original HTML document. With the exception of comment, dynamically generated HTML sections and JSP content substitutions. The scripting logic, except for where desired, is completely non visual in regard to the response HTML text.
The construction of the HTML layout conceivably begins with a Web developer. The creation of the JSP pages would be similar if not identical to the methods used to construct industry HTML pages. The next step would be the addition of JSP specific logic to identify the sections of the HTML that might be generated dynamically. This conversion step from pure HTML to JSP is where server side logic is added to the page.
A completed JSP logically embodies presentation layer services and business functionality. Physically they are blended within the JSP in an as needed swapping of HTML and JSP code. Continued maintenance of the application and changes in the business logic need not affect the presentation layout. Likewise, changes in the presentation layout need not affect the scriptlet logic, it will however require that the WEB developer, not necessarily a JAVA programmer, show care in the handling of this file which is no longer pure HTML should any HTML maintenance become necessary.
The Alternative
A design consideration intended to reduce the complexity of maintaining the HTML aspect of a JSP is to minimize the use of scriptlets in constructing a JSP. Custom tags, introduced in JSP 1.1, can equally produce the functionality provided by JSP scriptlets.
Custom tags are application defined language extensions to Java Server Pages. Custom tags can be used within a JSP in the following ways:
- to produce html output
- to produce JSP output (JSP expressions, directives, ...)
- to create objects
- to define objects that can be seen as scripting variables within the parent JSP
- to iterate over a body of JSP/HTML text in a finite manner
- to determine if section of the calling JSP should be processed or skipped
The goal of using custom tags to minimize the presence of scriptlets is to produce a more HTML ?like JSP. The advantages of this goal are self-evident if we consider projects that expect frequent HTML modifications. Assuming the business logic, pre-presented by the JSP tags, is stable it can be identically merged into various forms of the HTML layout, without explicitly inserting duplicate sections of scriptlet logic (Java code).
Tag handlers implement JSP custom tags. One or more tag handlers can be listed in the Tag Library Descriptor files. References to these files are included in the JSP that intends to use a given tag handler. The tag handler itself is implemented as a Java object that extends the JSP body. Upon execution it has access capabilities to the JSP's Http servlet objects, page attribute and session attribute objects. It can, conceivably, provide a full HTML response to the client in the way that servlets operate. A significant distinction from Java Server Pages is that tag handlers are not designed to be dynamically compiled by the server.
In respect to EJB's, a tag handler accesses an EJB in the same manner as the above scriptlet. It can additionally make available any object it creates, available to other tag handlers and JSP抯. This is accomplished by the use of storage methods that operate within the scope of the page and session. This includes the retention of EJB remote interface objects that can be created once and re-used by subsequent JSP抯 via scriptlets or tags.
The previous JSP example implemented using custom tags might appear as follows:
<%taglib declaration; prefix=tagpre%> <html> <title>E-commerce Site</title> <body> <tagpre:lookupCustomer> Welcome <%=CustomerName%> we look forward to processing your needs. <br> <%=CustomerCompany%> is one of our favorite companies to work with. </tagpre:lookupCustomer> </body> </html> |
As stated previously, the JSP engine and Java Server Pages logically produce presentation layer services. They also provide the interface to business services (i.e. EJB抯). The physical separation of the logic associated with these middle tier components is evident in the above example. The same EJB logic in the previous example is represented here by the tag references.
Figure 2 gives a graphical representation of the physical control flow without the use of custom tags. The client initiates execution with a JSP request. The request via URL is directed to the WEB server that is responsible for servicing such requests. The JSP request triggers the JSP engine to locate and execute the corresponding JSP as a servlet object. The execution of the business logic is represented by the use of Enterprise Java Beans.
Logically identical, figure 3 illustrates the use of tag handlers by the JSP. This is the hidden logic implied in HTML example 2.
The JSP engine, in both figures, treats the compiled JSP object as a servlet object. Figure 3抯 tag handler object extends the JSP page body. This relationship grants tag handler access to various servlet attributes. These attributes therefore permit the tag handler to conceivably inspect parameters passed by the client.
Conclusion
As with other tools of the trade, innovations and nuances to existing tools do not invalidate existing design methodologies. They do however provide new versatility and the expansion of possibilities with regard to application design.
Custom tag extensions, in contrast to standard tags, provide the application builder the ability to define custom tags to satisfy some functionality not provided by the standard API. To benefit by using tag extensions to reduce the amount of Java functionality that the JSP API provides, might seem oxymorinic, and it is. With the exception of dynamically compiled JSP抯, the functionality provided by the two given examples are identical, which suggests that the payoff for implementing this server side alternative is purely cosmetic, and it is.
While a server side application designer does not typically consider the cosmetic aspect of implementing source code, JSP source code might prove to be the exception. It does after all suggest the strong possibility that a Web/HTML developer perform the continued maintenance of the HTML portion of the JSP. This is a role, of course, traditionally allied with client side responsibilities.
The nuances introduced by JSP custom tags present nuances in the maintenance of JSP抯. The arguments presented here presume that the HTML produced by the JSP抯 in discussion are non-trivial HTML documents, although non-complex HTML documents may benefit from similar design considerations.
~end of Aurora Information Systems' White Paper Series #9
"JSP Design Notes"~
发表评论
-
Java字典:如何从程序员升级到架构师.
2012-03-24 23:32 0最近好多同学问学习java ... -
一个Java程序员应该掌握的10项技能
2011-12-08 12:56 9061、语法:必须比较熟 ... -
自定义log4j中的DailyRollingFileAppender
2011-03-11 22:47 4059需求: 日志内容是自定义的。例如,登录信息记录到一个日志文 ... -
google 测试
2010-05-11 16:32 781在Google,测试有一个721的原则:70%的测试工作在底层 ... -
项目测试风险总结
2009-12-01 11:38 993随着项目规模的扩大,项目的复杂性也逐渐增加,在项目中做好风险控 ... -
性能测试总结之性能监控篇
2009-12-01 11:35 1587在性能测试的整个流程当中,监控起着至关重要的作用。因为在性 ... -
如何编写高质量的Java代码
2009-10-14 09:17 1174如何编写高质量的Java代码: 1、 养成良好的习惯及 ... -
一直在用的类注释
2009-10-10 09:17 697/** * @Filename: ${file_na ... -
rapid-framework 连接 oracle时的一个bug
2009-04-28 17:40 2181在连接oracle数据库时报错: Exception ... -
xapool的框架配置
2008-12-17 10:31 2728package juan.orm.datasource.imp ... -
NIO socket服务器注意的几点.
2008-12-06 17:36 4357当你看到这篇文 ... -
jsp分页
2004-06-23 04:26 890******************************* ... -
解决jsp中乱码问题
2004-06-23 04:28 732数据库存储最好用8859_1的格式,所以存入数据库的时候进行一 ... -
使用类文件的数据库连接方法
2004-06-23 04:34 630******************************* ... -
jsp中文显示问题
2004-06-23 04:40 54510:30 2003-11-29 InberGong整理&l ... -
不用数据源直接连sqlserver数据库(jsp,中文)
2004-06-23 04:43 852//////////////整理InberGong10:22 ... -
WINDOWS 2000 环境下JAVA环境配置
2004-06-23 04:44 946//////////////整理InberGong10:22 ... -
Java 学习方法浅谈(http://www.javaeye.com站长Robbin著)
2004-07-01 02:51 678Java本身是一种设计的非 ... -
解决java中文问题的一些资源
2004-07-01 02:54 756解决java中文问题的一些资源 我收集了一些这方面的文章, 希 ... -
JAVA程序桥联数据库
2004-07-02 12:11 804/****************************** ...
相关推荐
《JSP设计》第三版是JSP开发领域的一本权威指南,它深入浅出地讲解了如何有效地构建动态Web应用程序。这本书旨在帮助开发者理解和掌握JavaServer Pages(JSP)技术,以便在实际项目中实现高效、可维护和可扩展的Web...
**JSP技术** JSP(JavaServer Pages)是Java平台上的动态网页技术,它允许开发者在HTML、XML或其他标记语言中嵌入Java代码,从而实现服务器端的动态内容生成。JSP的核心在于将表现层逻辑与业务逻辑分离,提供更灵活...
jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp模板jsp...
本资源"JSP.design.classic.menu.WEBtree.rar_jsp menu"显然是一个关于JSP菜单设计的经典代码示例,特别是使用了WEBtree这一概念来构建菜单结构。 WEBtree通常指的是在Web应用中用来展示层级数据的一种树形结构。在...
《CodeNotes for J2EE - EJB, JDBC, JSP and Servlet》这本书是针对Java企业级应用开发的一份宝贵资源,主要涵盖了四个关键的技术领域:Enterprise JavaBeans(EJB),Java Database Connectivity(JDBC),Java...
【Jsp 网站项目web design】是一个适合初学者的网上购物网站开发教程,它主要基于HTML(超文本标记语言)进行构建,旨在帮助学习者掌握网页设计和开发的基本概念。HTML是互联网上最基础的页面内容描述语言,通过一...
AntDesign,全称为"Ant Design",是一款源自阿里巴巴的优秀前端UI框架,专门用于构建企业级的Web应用。它的设计理念是“移动优先”,注重简洁、高效、可扩展性,为开发者提供了一整套完整的组件库,使开发人员能够...
jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与实现jsp论坛设计与...
【标题】"jsp网上商城jsp课程设计"是一个基于JavaServer Pages (JSP) 技术构建的电子商务平台项目。在JSP中,开发者通常利用HTML、CSS和JavaScript来设计用户界面,同时结合Java代码来处理服务器端逻辑。这个课程...
list_notes.jsp 发布内容显示和查询结果显示页面 insert.jsp 添加新内容页面 。。。。。。。。。。。。 使用到的数据:db_jsp.sql【位于项目的web页中】 使用方法一: 使用mysql命令行: create database db_...
动作元素如`<jsp:include>`, `<jsp:forward>`, `<jsp:params>`等,它们提供更高级的功能,如页面包含和转发。 2. **JSP生命周期**:JSP页面在服务器上经历解析、编译、加载、实例化、初始化、服务和销毁等阶段。在...
jsp 教案 jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp 教案jsp ...
JSP实例代码 JSP实例代码 JSP实例代码 JSP实例代码 JSP实例代码 JSP实例代码JSP实例代码 JSP实例代码 JSP实例代码 JSP实例代码
通过《jsp200问》解决实际问题,《jsp全攻略》全面覆盖JSP知识点,《jsp通用模块》教你如何构建可复用组件,《JSP技术手册》是详细的参考文档,《JSP由浅入深》则引导你逐步深入,而《图解JSP环境安装配置》则让你...
jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序 jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序jsp web程序 jsp web程序jsp web程序...
【JSP图书借阅系统(jsp+SQLServer)】是一个基于Java Server Pages(JSP)技术和SQL Server 2000数据库开发的图书借阅管理应用程序。这个系统旨在提供一个高效、用户友好的平台,方便图书馆管理员进行图书的借阅、...
《jsp实用案例教程》是一本由冯燕奎和赵德奎等专家共同编著的专业书籍,主要针对Java Server Pages(JSP)技术,为读者提供了丰富的实践案例,帮助学习者深入理解和掌握JSP在实际开发中的应用。本书不仅讲解了JSP的...
**JSP应用开发详解** JavaServer Pages(JSP)是一种基于Java技术的动态网页开发工具,它允许开发者在HTML、XML或者其他标记语言中嵌入Java代码,以实现服务器端的程序逻辑。JSP的出现极大地简化了Web应用程序的...
在IT行业中,JSP(JavaServer Pages)是一种用于创建动态网页的技术,它允许开发者使用Java语言来编写网页内容。本文将深入探讨“JSP文件在线预览”这一主题,涵盖其核心概念、实现原理以及相关的技术栈。 首先,...
jsp+struct资源 jsp+struct资源 jsp+struct资源jsp+struct资源jsp+struct资源jsp+struct资源jsp+struct资源jsp+struct资源 jsp+struct资源 jsp+struct资源 jsp+struct资源 jsp+struct资源