📄 2.htm
字号:
<td style="line-height: 25px"><font size="2" style="line-height: 25px">X</font></td>
</tr>
<tr style="line-height: 25px">
<td style="line-height: 25px"><font size="2" style="line-height: 25px">
Cascading Style Sheets</font></td>
<td style="line-height: 25px">
<font face="arial" size="2" style="line-height: 25px"> </font></td>
<td style="line-height: 25px"><font size="2" style="line-height: 25px">X</font></td>
<td style="line-height: 25px"><font size="2" style="line-height: 25px">X</font></td>
</tr>
<tr style="line-height: 25px">
<td style="line-height: 25px"><font size="2" style="line-height: 25px">
动态HTML</font></td>
<td style="line-height: 25px">
<font face="arial" size="2" style="line-height: 25px"> </font></td>
<td style="line-height: 25px">
<font face="arial" size="2" style="line-height: 25px"> </font></td>
<td style="line-height: 25px"><font size="2" style="line-height: 25px">X</font></td>
</tr>
</table>
</center>
<p><font face="arial" color="#3e72d7" size="4" style="line-height: 25px">
<b style="line-height: 25px">用户端技术的限制<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
完全依靠用户端技术来开发应用程式尽管是有可能的,但这些应用程式在能力上总有些限制,正如主从式架构一样。下列几个原因说明了为什麽主从式架构不适合用於网际网路上企业级的应用程式。</font></p>
<font face="arial" color="#000000" size="2" style="line-height: 25px">
<ul style="line-height: 25px">
<li style="line-height: 25px">
不是所有浏览器都支援使用用户端ActiveX控制项或用户端指令档的用户端应用程式。网际网路上的商业化应用程式应尽量适用於愈多的浏览器,包括那些不支援HTML表格、框架、Java小程式、用户端指令档或ActiveX控制项的浏览器。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">
作为用户端指令档的编码商务逻辑并无法保护您所设计的程式(因为任何人都可以得到程式码)。Java小程式和ActiveX控制项则较安全些,但如果将商务逻辑与使用者介面整合,应用程式就难以支援和测试。另外,进而产生的元件在其他应用程式中可重覆使用的可能性也更小。<br style="line-height: 25px">
</li>
<li style="line-height: 25px">
以用户端为中心的应用程式并未完全利用叁层程式模型的优势。设计中若用户端的工作不仅仅是支援时,这项工作由伺服器来完成会更加合适。如资源管理和资料控制等工作。<br style="line-height: 25px">
</li>
</ul>
</font><a name="202003" style="line-height: 25px">
<p><font face="arial" color="#3e70d7" size="5" style="line-height: 25px">
<b style="line-height: 25px">中间层<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
本节讨论中间层,它可能是Web程式中最重要的一层。在此层中,使用者输入与商务逻辑联合在一起执行网站的工作。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
中间层并非只是一个逻辑层,而是由许多相关的技术组成,这些技术连结在一起来组成这个多功能的层。例如,用户端的请求可由Internet Server
Application Programming Interface(ISAPI)筛选器来预先处理,然後执行指令档以便执行使用ADO来控制资料库的自订元件。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
在本节讨论的中间层技术包括CGI(Common Gateway Interface)应用程式、ISAPI延伸和筛选器、ASP、程序隔离等技术。</font></p>
<p><font face="arial" color="#3e72d7" size="4" style="line-height: 25px">
<b style="line-height: 25px">CGI应用程式<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
过去设计Web伺服器应用程式通常会要求开发CGI程式或指令档。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
CGI应用程式广泛地用在UNIX系统上,以建立在Web伺服器上执行的可执行程式。CGI程式通常用C语言写成,但也可以用解译语言如Perl来编写。如果远端使用者要启动在伺服器上的CGI应用程式,他只需请求一个带有CGI
应用程式名称的URL就可以实施。在URL问号後的参数被当作环境字串传给 CGI应用程式。CGI应用程式的输出与桌面应用程式的输出并没有很大的区别,
HTTP标头和HTML都是由语言的基本输出函式产生(如C语言中的 <程式码>printf</程式码>)。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
CGI应用程式容易编写,但在Windows作业系统上不是很流行。因为每个用户端请求都会产生一个单独的程序,若有上百个使用者,就必须建立上百个
CGI程式的例项,且每个例项都要求有自己的记忆体空间和系统资源。这对UNIX
并不是很糟糕的情况,因为它的设计就是能处理多个程序,且只需少量的成本;然而,在能为程序内的执行绪管理作最佳化的Microsoft Windows
2000於建立和销毁应用程式例项时,却会消耗更多的系统资源。因此,ISAPI是专为IIS 5.0所开发,以替代Windows来提高CGI之效能。</font></p>
<p><font face="arial" color="#3e72d7" size="4" style="line-height: 25px">
<b style="line-height: 25px">ISAPI延伸和筛选器<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">ISAPI延伸是即时动态连结库,它通常被装载在IIS
5.0同一记忆体位址空间里。因为它是个动态连结库,所以一次只需装入ISAPI延伸的一个例项。当然, ISAPI延伸必须是安全执行绪(thread-safe),才能同时收到多个用户端的请求。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">虽然ISAPI延伸远比CGI应用程式复杂,但是ISAPI使用一个较简单的应用程式发展介面(Application
Programming Interface, API)。对於每个用户端请求,Web伺服器使用<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> HttpExtensionProc </b></font>ISAPI呼叫,并传递一个指标到ISAPI
Extension Control Block(ECB),这个指标中包含了请求的资讯。ISAPI
动态连结可以使用伺服器回应功能,以存取如伺服器变数之类的资讯。ISAPI ECB也可以让开发人员存取一般的支援功能,如URL重新导向、工作阶段管理、和在CGI应用程式里没有的回应标头。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
尽管与CGI相比,ISAPI延伸有显着的优点,但它也带来一些维护上的困难。例如,对於由ISAPI延伸传回的HTML,即便再小的变更也要重新进行编译和连结;同时,如果一个ISAPI
DLL在部署及在Web伺服器程序中执行前没有经过彻底的测试和验证,它可能会使Web伺服器当机。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
您可以选择哪一个ISAPI延伸要与IIS
5.0一起载入程序,哪一个延伸应被安装为独立程序。ISAPI延伸是一个独立的程序,可以在伺服器程序外独立停止或重新启动,在当机之後,它也能自动重新启动。虽然程序外延伸比程序内延伸要慢,但是由於它能够隔离和重新载入仍在开发的应用程式,所以在服务的可靠性方面,仍然有其优势。有关程序外延伸更详细的资讯,请参阅本书 </font></a><font face="arial" color="#000000" size="2" style="line-height: 25px"><a target="_new" href="http://e-msbooks.com/relaunch/XML/paser.asp?src=957-2085-16-6_203.xml#203" style="line-height: 25px">第3章〈资料存取与交易处理〉</a> 。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">ISAPI也可以用来建立<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> ISAPI筛选器 </b></font>。筛选器在Web伺服器延伸性方面是一个相当新的概念。ISAPI筛选器能在伺服器处理一些特定的伺服器事件之前,先将这些事件留下来处理,其呼叫习惯和延伸的呼叫习惯非常相似。筛选器一经载入(通常是在Web服务开始时)就表明它将处理的事件通知类型,一但发生这些事件,筛选器处理事件的选择有:将它们传给其他筛选器,或将事件发给伺服器。这样,ISAPI筛选器可用来提供自订的验证技术,或根据用户端发来的HTTP标头自动重新定向请求,如<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Accept-Language </b></font>。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
然而,未经仔细编写的筛选器是会降低效能的。ISAPI筛选器可以与IIS 5.0
一起,在Web伺服器上作为一个整体装载,或为特定网站而载入,只是它们不能在程序外执行。</font></p>
<p><font face="arial" color="#3e72d7" size="4" style="line-height: 25px">
<b style="line-height: 25px">Active Server Pages<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP指令档环境大大简化了伺服器端程式,因而简化了建立动态内容以及强大的、以Web为基础的应用程式过程。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP网页中的指令档能够执行和CGI与ISAPI应用程式同样的工作,且在编写和修改上都容易许多。ASP透过管理伺服器上的应用程式和工作阶段作业状态,以建立互动性更高的层次,进而减少伺服器和用户端之间所需的资讯传输。ASP使得输入资料到HTML表单或与作为URL参数之资讯的工作变得简单。您也可以控制来自用户端Cookie和用户端安全凭证的进阶HTTP功能。有关进阶功能更详细的资讯,请参阅IIS
5.0线上说明文件。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP的核心是一个ISAPI延伸—Asp.dll,它在执行时使用一个指令档解译器编译在记忆体中的 .asp档案,并将档案放入快取中。<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> IIS
5.0指令档对应 </b></font>(script map)将 .asp延伸和Asp.dll关联起来,因为ASP在执行指令档之前必须先加以解释和编译,所以复杂的指令档<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> 在被第一次请求时 </b></font>,其速度可能会比普通HTML慢四倍,比ISAPI慢二到叁倍;之後,编译过的网页被放入伺服器的快取,从而使得之後请求的速度大大提高,并在潜在的上千个网页请求中逐步抵消开始的编译时间。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP是为可用性和易开发而设计的,能让您大大减少花在开发上的时间,但是它永远无法比静态内容或自订的、目的集中的ISAPI延伸做得更好。只有用心编写的ASP应用程式,加上伺服器端元件才能增进ISAPI应用程式的效能和速度。有关设计ASP网页的资讯,请参阅IIS
5.0线上说明文件中〈建构ASP网页〉的解说。</font></p>
<p><font face="arial" color="#3e74d7" size="3" style="line-height: 25px">
<b style="line-height: 25px">ASP伺服器端指令档<br style="line-height: 25px">
</b></font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
您可以建立不需依赖浏览器类型就能存取且高度互动的网页。与用户端指令档不同的是,使用ASP可以在伺服器上「隐藏」您的指令档,以保护您的开发创意和智慧财产权。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP指令档环境并不限制采用的语言为何,如VBScript、Microsoft Jscript 或者其他任何具有协力厂商ActiveX指令档引擎的语言,如Perl
Script、PEXX 或Python等都能做为建立ASP网页的指令档。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
ASP指令档指令是与HTML一起出现(事实上,只要将普通的HTML网页档案的副档名改为 .asp,就建立了ASP网页)。为了区分在伺服器上执行的
HTML和指令档, ASP使用特定的标记,称为<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> 伺服器端指令档分隔符号 </b></font>:<%和%>,以标明伺服器端的指令档。在处理网页时,出现在这些分隔符号内的指令档将在伺服器上呼叫。这些指令档分隔符号中的一个特殊形式:<%=
expression %> 能做为指令档传回值的简写。</font></p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
下面的伺服器端VBScript程式码会传回目前时间:</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px">Today is <%= Date %>.</pre>
</font>
</div>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
该指令产生类似下面的结果(正确的内容取决於目前的日期):</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px">Today is 7/4/99.</pre>
</font>
</div>
<hr style="line-height: 25px">
<p>
<font face="Arial" color="#3e77d7" size="3" Black style="line-height: 25px">
<b style="line-height: 25px">说明</b></font> </p>
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
您也可以使用ASP<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Response </b></font>物件的<font face="arial" color="#3e80d7" size="2" style="line-height: 25px"><b style="line-height: 25px"> Write </b></font>方法来显示文字或网页上一个表达式的结果。</font></p>
<hr style="line-height: 25px">
<p><font face="arial" color="#000000" size="2" style="line-height: 25px">
稍微复杂的ASP范例可能会混合使用指令档的条件语法与HTML,如下所示:</font></p>
<div style="line-height: 25px; background-color: #d7d7d7">
<font face="Arial" size="3" style="line-height: 25px">
<pre style="line-height: 25px"><% If Hour (Now) < 12 Then %>
<FONT COLOR = YELLOW> Good Morning! </FONT>
<%ElseIf Hour (Now) < 18 Then %>
<FONT COLOR = LIME> Good Afternoon! </FONT>
<% Else %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -