【正文】
sed many of the same special tags as ASP did. So, the question bees: why use JSP instead of one of these other technologies? Our first response is that we are not arguing that everyone should. Several of those other technologies are quite good and are reasonable options in some situations. In other situations, however, JSP is clearly better. Here are a few of the .NET and Active Server Pages (ASP).NET is welldesigned technology from Microsoft. is the part that directly petes with servlets and JSP. The advantages of JSP are , JSP is portable to multiple operating systems and Web servers。 you aren39。t provide any capabilities that couldn39。t understand servlet programming. 3. Some tasks are better acplished by servlets than by JSP. JSP is good at generating pages that consist of large sections of fairly well structured HTML or other character data. Servlets are better for generating binary data, building pages with highly variable structure, and performing tasks (such as redirection) that involve little or no output. 4. Some tasks are better acplished by a bination of servlets and JSP than by either servlets or JSP alone. Versus , which is pletely distinct from the Java programming language, is normally used to dynamically generate HTML on the client, building parts of the Web page as the browser loads the document. This is a useful capability and does not normally overlap with the capabilities of JSP (which runs only on the server). JSP pages still include SCRIPT tags for JavaScript, just as normal HTML pages do. In fact, JSP can even be used to dynamically generate the JavaScript that will be sent to the client. So, JavaScript is not a peting technology。 you just put the image in the directory for Web resources (., two levels up from WEBINF/classes) and output a normal IMG create images that change under the mouse by using clientside JavaScript, referenced with the SCRIPT tag。 Loading into memory, initialization, and execution follow the normal rules for servlets. 中文翻譯 JSP技術概述 JSP頁面最終會轉換成 servler。畢竟,在特定平臺上能夠用 Java編程語言完成的事情,同樣可以用匯編語言來完成,但是選擇哪種語言依舊十分重要。 Java程序員可以致力于動 態(tài)代碼。 在此,這個討論并不是讓您停止使用 servlets,只使用 JSP。 JSP相對于競爭技術的優(yōu)勢許多年前, Marty受到邀請 ,參加一個有關軟件技術的小型 (20個人 )研討會 .做在 Marty旁邊的人是 James Gosling Java編程語言的發(fā)明者。 Java社團沒有發(fā)明這一思想 將頁面設計成由靜態(tài) HTML和用特殊標簽標記的動態(tài)代碼混合組成 .。 因此 ,問題變成 :為什么使用 JSP,而不使用其他技術呢 ?我們的第一反應是我們不是在爭論所有的人應該做什么。 JSP的優(yōu)勢體現(xiàn)在兩個方面: 首先 ,JSP可以移植到多種操作系統(tǒng)和 Web服務器 ,您不必僅僅局限于部署在 Windows 和 IIS 上盡管核心 .NET平臺可以在好幾種非 Windows平臺上運行,但 ASP這一部分不可以。其次,對于某些應用,底層語言的選擇至關重要。使用 JSP,動態(tài)部分是用 Java 編寫的 ,而非 VBScript過其他 ASP專有的語言 ,因此 JSP更為強勁 ,更適合于要求組件重用的復雜應用。 與 PHP相比, PHP( “PHP: Hypertext Preprocessor”的遞歸字母縮寫詞)是免費的、開放源代碼的、 HTML 嵌入其中的腳本語言,與 ASP 和 JSP 都有某種程度的類似。實際上, JSP文檔在后臺被自動轉換成 Servlet。不了解 Servlet就無法知道 JSP如何工作。 JSP擅長生成由大量組織有序的結構化 HTML 或其他字符數(shù)據(jù)組成的頁面。這是一項有用的功能,一般與 JSP的功能(只在服務器端運行)并不發(fā)生重疊。然而, Java更為強大靈活、可靠且可移植。因此,在后續(xù)版本中,這項技術能夠得到協(xié)調的改進。但是,試圖使用非標準的工具代替 JSP則不理想。所有 JSP兼容的服務器必須支持這些標準。例如, JSP標準標簽庫和 JSP 語言解決了兩種最廣泛的批評:缺乏良好的迭代結構;不使用顯式的 Java 代碼或冗長的 jsp:useBean元素難以訪問動態(tài)結果。 Tomcat不支持 JavaScript,當用戶在圖像上移動鼠標時,我如何使圖像突出顯示呢?我們的客戶使用不理解 JSP的舊瀏覽器。如果瀏覽器支持 Java 2平臺,您可以使用正常的 APPLET(或 Java插件)標簽,即使在服務器上使用了非 Java技術也須如此。因此,如同對待靜態(tài) HTML頁面一樣,只需確保 JSP輸出的 HTML與瀏覽器兼容。但是每一步發(fā)生在什么時候呢?要回答這個問題,要記住以下兩點: JSP頁面僅在修改后第一次被訪問時,才會被轉換成 servlet并進行編譯;載入到內存中 、初始化和執(zhí)行遵循 servlet的一般規(guī)則。混淆轉換期間和請求期