THE TECHNIQUE DEVELOPMENT HISTORY OF JSP
By:Kathy Sierra and Bert Bates
Source: Servlet&JSP
The Java Server Pages( JSP) is a kind of according to web of the script plait distance
technique, similar carries the script language of Java in the server of the Netscape company of
server- side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP
compares the SSJS and ASP to have better can expand sex, and it is no more exclusive than
any factory or some one particular server of Web. Though the norm of JSP is to be draw up by
the Sun company of, any factory can carry out the JSP on own system.
The After Sun release the JSP( the Java Server Pages) formally, the this kind of new
Web application development
technique very quickly caused the people's concern. JSP
provided a special development environment for the Web application that establishes the high
dynamic state. According to the Sun parlance, the JSP can adapt to include the Apache
WebServer, IIS4.0 on the market at inside of 85% server product.
This chapter will introduce the related knowledge of JSP and Databases, and JavaBean
related contents, is all certainly rougher introduction among them basic contents, say perhaps
to is a Guide only, if the reader needs the more detailed information, pleasing the book of
consult the homologous JSP.
1.1 GENERALIZE
The JSP(Java Server Pages) is from the company of Sun Microsystems initiate, the many
companies the participate to the build up the together of the a kind the of dynamic the state
web the page technique standard, the it have the it in the construction the of the dynamic state
the web page the strong but the do not the especially of the function. JSP and the technique of
ASP of the Microsoft is very alike. Both all provide the ability that mixes with a certain
procedure code and is explain by the language engine to carry out the procedure code in the
code of HTML. Underneath we are simple of carry on the introduction to it.
JSP pages are translated into servlets. So, fundamentally, any task JSP pages can perform
could also be accomplished by servlets. However, this underlying equivalence does not mean
that servlets and JSP pages are equally appropriate in all scenarios. The issue is not the power
of the technology, it is the convenience, productivity, and maintainability of one or the other.
After all, anything you can do on a particular computer platform in the Java programming
language you could also do in assembly language. But it still matters which you choose.
1
JSP provides the following benefits over servlets alone:
• It is easier to write and maintain the HTML. Your static code is ordinary HTML: no
extra backslashes, no double quotes, and no lurking Java syntax.
• You can use standard Web-site development tools. Even HTML tools that know
nothing about JSP can be used because they simply ignore the JSP tags.
• You can divide up your development team. The Java programmers can work on the
dynamic code. The Web developers can concentrate on the presentation layer. On large
projects, this division is very important. Depending on the size of your team and the
complexity of your project, you can enforce a weaker or stronger separation between the static
HTML and the dynamic content.
Now, this discussion is not to say that you should stop using servlets and use only JSP
instead. By no means. Almost all projects will use both. For some requests in your project,
you will use servlets. For others, you will use JSP. For still others, you will combine them
with the MVC architecture . You want the appropriate tool for the job, and servlets, by
themselves, do not complete your toolkit.
1.2 SOURCE OF JSP
The technique of JSP of the company of Sun, making the page of Web develop the
personnel can use the HTML perhaps marking of XML to design to turn the end page with
format. Use the perhaps small script future life of marking of JSP becomes the dynamic state
on the page contents.( the contents changes according to the claim of)
The Java Servlet is a technical foundation of JSP, and the large Web applies the
development of the procedure to need the Java Servlet to match with with the JSP and then
can complete, this name of Servlet comes from the Applet, the local translation method of
now is a lot of, this book in order not to misconstruction, decide the direct adoption Servlet
but don't do any translation, if reader would like to, can call it as" small service procedure".
The Servlet is similar to traditional CGI, ISAPI, NSAPI etc. Web procedure development the
function of the tool in fact, at use the Java Servlet hereafter, the customer need not use again
the lowly method of CGI of efficiency, also need not use only the ability come to born page of
Web of dynamic state in the method of API that a certain fixed Web server terrace circulate.
Many servers of Web all support the Servlet, even not support the Servlet server of Web
directly and can also pass the additional applied server and the mold pieces to support the
Servlet. Receive benefit in the characteristic of the Java cross-platform, the Servlet is also a
terrace irrelevant, actually, as long as match the norm of Java Servlet, the Servlet is complete
to have nothing to do with terrace and is to have nothing to do with server of Web. Because
the Java Servlet is internal to provide the service by the line distance, need not start a progress
2
to the each claimses, and make use of the multi-threading mechanism can at the same time for
several claim service, therefore the efficiency of Java Servlet is very high.
But the Java Servlet also is not to has no weakness, similar to traditional CGI, ISAPI, the
NSAPI method, the Java Servlet is to make use of to output the HTML language sentence to
carry out the dynamic state web page of, if develop the whole website with the Java Servlet,
the integration process of the dynamic state part and the static state page is an evil-foreboding
dream simply. For solving this kind of weakness of the Java Servlet, the SUN released the
JSP.
A number of years ago, Marty was invited to attend a small 20-person industry
roundtable discussion on software technology. Sitting in the seat next to Marty was James
Gosling, inventor of the Java programming language. Sitting several seats away was a
high-level manager from a very large software company in Redmond, Washington. During
the discussion, the moderator brought up the subject of Jini, which at that time was a new
Java technology. The moderator asked the manager what he thought of it, and the manager
responded that it was too early to tell, but that it seemed to be an excellent idea. He went on to
say that they would keep an eye on it, and if it seemed to be catching on, they would follow
his company's usual "embrace and extend" strategy. At this point, Gosling lightheartedly
interjected "You mean disgrace and distend."
Now, the grievance that Gosling was airing was that he felt that this company would
take technology from other companies and suborn it for their own purposes. But guess what?
The shoe is on the other foot here. The Java community did not invent the idea of designing
pages as a mixture of static HTML and dynamic code marked with special tags. For example,
Cold Fusion did it years earlier. Even ASP (a product from the very software company of the
aforementioned manager) popularized this approach before JSP came along and decided to
jump on the bandwagon. In fact, JSP not only adopted the general idea, it even used many of
the same special tags as ASP did.
The JSP is an establishment at the model of Java servlets on of the expression layer
technique, it makes the plait write the HTML to become more simple.Be like the SSJS, it also
allows you carry the static state HTML contents and servers the script mix to put together the
born dynamic state exportation. JSP the script language that the Java is the tacit approval,
however, be like the ASP and can use other languages( such as JavaScript and VBScript), the
norm of JSP also allows to use other languages.
1.3JSP CHARACTERISTICS
Is a service according to the script language in some one language of the statures
system this kind of discuss, the JSP should be see make is a kind of script language.
3
However, be a kind of script language, the JSP seemed to be too strong again, almost can
use all Javas in the JSP.
Be a kind of according to text originally of,
take manifestation as the central
development technique, the JSP provided all advantages of the Java Servlet, and, when
combine with a JavaBeans together, providing a kind of make contents and manifestation that
simple way that logic separate. Separate the contents and advantage of logical manifestations
is, the personnel who renews the page external appearance need not know the code of Java,
and renew the JavaBeans personnel also need not be design the web page of expert in hand,
can use to take the page of JavaBeans JSP to define the template of Web, to build up a from
have the alike external appearance of the website that page constitute. JavaBeans completes
the data to provide, having no code of Java in the template thus, this means that these
templates can be written the personnel by a HTML plait to support. Certainly, can also make
use of the Java Servlet to control the logic of the website, adjust through the Java Servlet to
use the way of the document of JSP to separate website of logic and contents.
Generally speaking, in actual engine of JSP, the page of JSP is the edit and translate type
while carry out, not explain the type of. Explain the dynamic state web page
development
tool of the type, such as ASP, PHP3 etc., because speed etc. reason, have already can't satisfy
current the large electronic commerce needs appliedly, traditional development techniques are
all at to edit and translate the executive way change, such as the ASP → ASP+;PHP3 →
PHP4.
In the JSP norm book, did not request the procedure in the JSP code part( be called the
Scriptlet) and must write with the Java definitely. Actually, have some engines of JSP are
adoptive other script languages such as the EMAC- Script, etc., but actually this a few script
languages also are to set up on the Java, edit and translate for the Servlet to carry out of. Write
according to the norm of JSP, have no Scriptlet of relation with Java also is can of, however,
mainly lie in the ability and JavaBeans, the Enterprise JavaBeanses because of the JSP strong
function to work together, so even is the Scriptlet part not to use the Java, edit and translate of
performance code also should is related with Java.
1.4JSP MECHANISM
To comprehend the JSP how unite the technical advantage that above various speak of,
come to carry out various result easily, the customer must understand the differentiation of"
the module develops for the web page of the center" and" the page develops for the web page
of the center" first.
The SSJS and ASP are all in several year ago to release, the network of that time is still
very young, no one knows to still have in addition to making all business, datas and the
4
expression logic enter the original web page entirely heap what better solve the method. This
kind of model that take page as the center studies and gets the very fast development easily.
However, along with change of time, the people know that this kind of method is unwell in set
up large, the Web that can upgrade applies the procedure. The expression logic write in the
script environment was lock in the page, only passing to shear to slice and glue to stick then
can drive heavy use. Express the logic to usually mix together with business and the data
logics, when this makes be the procedure member to try to change an external appearance that
applies the procedure but do not want to break with its llied business logic, apply the
procedure of maintenance be like to walk the similar difficulty on the eggshell. In fact in the
business enterprise, heavy use the application of the module already through very mature, no
one would like to rewrite those logics for their applied procedure.HTML and sketch the
designer handed over to the implement work of their design the Web plait the one who write,
make they have to double work- Usually is the handicraft plait to write, because have no fit
tool and can carry the script and the HTML contents knot to the server to put together. Chien
but speech, apply the complexity of the procedure along with the Web to promote
continuously, the development method that take page as the center limits sex to become to get
up obviously.
at look
for the
of build
spreads in
At the same time, the people always
up
better method
the Web application procedure, the module
customer's machine/ server the
realm. JavaBeans and ActiveX were published the company to expand to apply the
procedure developer for Java and Windows to use to come to develop the complicated
procedure quickly by" the fast application procedure development"( RAD) tool. These
techniques make the expert
in the some realm be able to write the module for the
perpendicular application plait in the skill area, but the developer can go fetch the usage
directly but need not control the expertise of this realm.
Be a kind of take module as the central development terrace, the JSP appeared. It with
the JavaBeans and Enterprise JavaBeans( EJB) module includes the model of the business and
the data logic for foundation, provide a great deal of label and a script terraces to use to come
to show in the HTML page from the contents of JavaBeans creation or send a present in return.
Because of the property that regards the module as the center of the JSP, it can drive Java and
not the developer of Java uses equally. Not the developer of Java can pass the JSP label( Tags)
to use the JavaBeans that the deluxe developer of Java establish. The developer of Java not
only can establish and use the JavaBeans, but also can use the language of Java to come to
control more accurately in the JSP page according to the expression logic of the first floor
JavaBeans.
5
See now how JSP is handle claim of HTTP. In basic claim model, a claim directly was
send to JSP page in. The code of JSP controls to carry on hour of the logic processing and
module of JavaBeanses' hand over with each other, and the manifestation result in dynamic
state bornly, mixing with the HTML page of the static state HTML code. The Beans can be
JavaBeans or module of EJBs. Moreover, the more complicated claim model can see make
from is request other JSP pages of the page call sign or Java Servlets.
The engine of JSP wants to chase the code of Java that the label of JSP, code of Java in
the JSP page even all converts into the big piece together with the static state HTML contents
actually. These codes piece was organized the Java Servlet that customer can not see to go to
by the engine of JSP, then the Servlet edits and translate them automatically byte code of Java.
Thus, the visitant that is the website requests a JSP page, under the condition of it is not
knowing, an already born, the Servlet actual full general that prepared to edit and translate
completes all works, very concealment but again and efficiently. The Servlet is to edit and
translate of, so the code of JSP in the web page does not need when the every time requests
that page is explain. The engine of JSP need to be edit and translate after Servlet the code end
is modify only once, then this Servlet that editted and translate can be carry out. The in view
of the fact JSP engine auto is born to edit and translate the Servlet also, need not procedure
member begins to edit and translate the code, so the JSP can bring vivid sex that function and
fast developments need that you are efficiently.
Compared with the traditional CGI, the JSP has the equal advantage. First, on the speed,
the traditional procedure of CGI needs to use the standard importation of the system to output
the equipments to carry out the dynamic state web page born, but the JSP is direct is mutually
the connection with server. And say for the CGI, each interview needs to add to add a progress
to handle, the progress build up and destroy by burning constantly and will be a not small
burden for calculator of be the server of Web. The next in order, the JSP is specialized to
develop but design for the Web of, its purpose is for building up according to the Web applied
procedure, included the norm and the tool of a the whole set. Use the technique of JSP can
combine a lot of JSP pages to become a Web
application procedure very expediently.
6
JSP 的技术发展历史
作者: Kathy Sierra and Bert Bates
来源: Servlet&JSP
Java Server Pages(JSP)是一种基于 web 的脚本编程技术,类似于网景公司的服务器
端 Java 脚本语言——server-side JavaScript(SSJS)和微软的 Active Server Pages(ASP)。与
SSJS 和 ASP 相比,JSP 具有更好的可扩展性,并且它不专属于任何一家厂商或某一特
定的 Web 服务器。尽管 JSP 规范是由 Sun 公司制定的,但任何厂商都可以在自己的系
统上实现 JSP。
在 Sun 正式发布 JSP(Java Server Pages)之后,这种新的 Web 应用开发技术很快引起
了人们的关注。JSP 为创建高度动态的 Web 应用提供了一个独特的开发环境。按照 Sun
的说法,JSP 能够适应市场上包括 Apache WebServer、IIS4.0 在内的 85%的服务器产品。
本文将介绍 JSP 相关的知识,以及 JavaBean 的相关内容,当然都是比较粗略的介绍其
中的基本内容,仅仅起到抛砖引玉的作用,如果读者需要更详细的信息,请参考相应的
JSP 的书籍。
1.1 概述
JSP(Java Server Pages)是由 Sun Microsystems 公司倡导、许多公司参与一起建立的
一种动态网页技术标准,其在动态网页的建设中有其强大而特别的功能。JSP 与 Microsoft
的 ASP 技术非常相似。两者都提供在 HTML 代码中混合某种程序代码、由语言引擎解
释执行程序代码的能力。下面我们简单的对它进行介绍。
JSP 页面最终会转换成 servlet。因而,从根本上,JSP 页面能够执行的任何任务都
可以用 servlet 来完成。然而,这种底层的等同性并不意味着 servlet 和 JSP 页面对于所
有的情况都等同适用。问题不在于技术的能力,而是二者在便利性、生产率和可维护性
上的不同。毕竟,在特定平台上能够用 Java 编程语言完成的事情,同样可以用汇编语言
来完成,但是选择哪种语言依旧十分重要。
和单独使用 servlet 相比,JSP 提供下述好处:
JSP 中 HTML 的编写与维护更为简单。JSP 中可以使用常规的 HTML:没有额外的
反斜杠,没有额外的双引号,也没有暗含的 Java 语法。
能够使用标准的网站开发工具。即使是那些对 JSP 一无所知的 HTML 工具,我们
也可以使用,因为它们会忽略 JSP 标签(JSP tags)。
可以对开发团队进行划分。Java 程序员可以致力于动态代码。Web 开发人员可以将
经理集中在表示层(presentation layer)上。对于大型的项目,这种划分极为重要。依据
开发团队的大小,及项目的复杂程度,可以对静态 HTML 和动态内容进行弱分离(weaker
separation)和强分离(stronger separation)。
7
此处的讨论并不是说人们应该放弃使用 servlet 而仅仅使用 JSP。事实上,几乎所有
的项目都会同时用到这两种技术。在某些项目中,更适宜选用 servlet,而针对项目中的
某些请求,我们可能会在 MVC 构架下组合使用这两项技术。我们总是希望用适当的工
具完成相对应的工作,仅仅是 servlet 并不一定能够胜任所有工作。
1.2 JSP 的由来
Sun 公司的 JSP 技术,使 Web 页面开发人员可以使用 HTML 或者 XML 标识来设计
和格式化最终页面。使用 JSP 标识或者小脚本来生成页面上的动态内容(内容是根据请
求来变化的)。
Java Servlet 是 JSP 技术的基础,而且大型的 Web 应用程序的开发需要 Java Servlet
和 JSP 配合才能完成,Servlet 这个名称源于 Applet,现在国内的翻译方式很多,本书为
了避免误会,决定直接采用 Servlet 而不做任何翻译,读者如果愿意,可以称之为“小服
务程序”。Servlet 其实和传统的 CGI、ISAPI、NSAPI 等 Web 程序开发工具的作用是相
似的,在使用 Java Servlet 以后,用户不必再使用效率低下的 CGI 方式,也不必使用只
能在某个固定 Web 服务器平台运行的 API 方式来动态生成 Web 页面。许多 Web 服务器
都支持 Servlet,即使不直接支持 Servlet 的 Web 服务器也可以通过附加的应用服务器和
模块来支持 Servlet。得益于 Java 的跨平台的特性,Servlet 也是平台无关的,实际上,
只要符合 Java Servlet 规范,Servlet 是完全与平台无关且是与 Web 服务器无关的。由于
Java Servlet 内部是以线程方式提供服务,不必对于每个请求都启动一个进程,并且利用
多线程机制可以同时为多个请求服务,因此 Java Servlet 效率非常高。
但 Java Servlet 也不是没有缺点,和传统的 CGI、ISAPI、NSAPI 方式相同,Java Servlet
是利用输出 HTML 语句来实现动态网页的,如果用 Java Servlet 来开发整个网站,动态
部分和静态页面的整合过程会非常难以实现。为了解决 Java Servlet 的这种缺点,SUN
推出了 JSP。
许多年前,Marty 受到邀请,参加一个有关软件技术的小型研讨会.坐在 Marty 旁边的
人是 James Gosling--- Java 编程语言的发明者。隔几个位置,是来自华盛顿一家大型软件
公司的高级经理。在讨论过程中,研讨会的主席提出了 Jini 的议题,这在当时是一项新的
Java 技术。主席向该经理询问他的想法.他回答说,虽然现在言之过早,但这看起来会是
非常有前途的一项技术。他们会持续关注这项技术,如果这项技术变得流行起来,他们会
遵循公司的“接受并扩充(embrace and extend)”的策略.此时, Gosling 随意地插话说“你的
意思其实就是不接受且不扩充(disgrace and distend)。”
在此, Gosling 的抱怨显示出,他感到这个公司会从其他公司那里拿走技术,用于他们
自己的目的.出人意料的是,形势已经完全不同。Java 团队并没有发明这一思想----将页
面设计成由静态 HTML 和用特殊标签标记的动态代码混合组成.。ColdFusion 多年前就
已经这样做了。甚至 ASP(来自于前述经理所在公司的一项产品)都在 JSP 出现之前推广
8