買這商品的人也買了...
-
$580$458 -
$680$537 -
$880$695 -
$1,029Operating System Concepts, 6/e (Windows XP Update)
-
$1,920$1,824 -
$780$741 -
$590$466 -
$690$538 -
$780$663 -
$780$616 -
$580$493 -
$750$638 -
$720$569 -
$560$476 -
$720$569 -
$780$663 -
$450$351 -
$850$723 -
$280$218 -
$480$379 -
$750$593 -
$720$569 -
$780$616 -
$780$663 -
$650$507
相關主題
商品描述
With literally hundreds of examples and thousands of lines of code, the
Java Servlet and JSP Cookbook yields tips and techniques that any Java
web developer who uses JavaServer Pages or servlets will use every day, along
with full-fledged solutions to significant web application development problems
that developers can insert directly into their own applications.
Java
Servlet and JSP Cookbook presents real-world problems, and provides concise,
practical solutions to each. Finding even one tested code "recipe" that solves a
gnarly problem in this comprehensive collection of solutions and best practices
will save hours of frustration--easily justifying the cost of this invaluable
book.
But "Java Servlet and JSP Cookbook" is more than just a wealth of
cut-and-paste code. It also offers clear explanations of how and why the code
works, warns of potential pitfalls, and directs you to sources of additional
information, so you can learn to adapt the problem-solving techniques to similar
situations.
These recipes include vital topics like the use of Ant to
setup a build environment, extensive coverage of the WAR file format and web.xml
deployment descriptor, file-uploading, error-handling, cookies, logging, dealing
with non-HTML content, multimedia, request filtering, web services, I18N, web
services, and a host of other topics that frustrate even the most seasoned
developers.
For Java web developers of all levels who are eager to put
into practice the theory presented in other API-focused books, the solutions
presented in this practical book will prove invaluable over and over again. This
is painless way for less experienced developers who prefer to learn by doing to
expand their skills and productivity, while accomplishing practical solutions to
the pressing problems they face every day. More experienced developers can use
these recipes to solve time-consuming problems quickly, freeing up their time
for the more creative aspects of their work.
Table of Contents
Preface
1. Writing Servlets and JSPs
1.1 Writing a Servlet
1.2 Writing a JSP
1.3 Compiling a Servlet
1.4 Packaging Servlets and JSPs
1.5 Creating the Deployment Descriptor2. Deploying Servlets and JSPs
2.1 Deploying an Individual Servlet on Tomcat
2.2 Using a Context Element in Tomcat's server.xml
2.3 Deploying an Individual Servlet on WebLogic
2.4 Deploying an Individual JSP on Tomcat
2.5 Deploying an Individual JSP on WebLogic
2.6 Deploying a Web Application on Tomcat
2.7 Deploying a Web Application on WebLogic Using Ant
2.8 Using the WebLogic Administration Console
2.9 Using WebLogic Builder to Deploy a Web Application
2.10 Using the weblogic.Deployer Command-Line Tool3. Naming Your Servlets
3.1 Mapping a Servlet to a Name in web.xml
3.2 Creating More Than One Mapping to a Servlet
3.3 Creating a JSP-Type URL for a Servlet
3.4 Mapping Static Content to a Servlet
3.5 Invoking a Servlet Without a web.xml Mapping
3.6 Mapping All Requests Within a Web Application to a Servlet
3.7 Mapping Requests to a Controller and Preserving Servlet Mappings
3.8 Creating Welcome Files for a Web Application
3.9 Restricting Requests for Certain Servlets
3.10 Giving Only the Controller Access to Certain Servlets4. Using Apache Ant
4.1 Obtaining and Setting Up Ant
4.2 Using Ant Targets
4.3 Including Tomcat JAR files in the Build File Classpath
4.4 Compiling a Servlet with an Ant Build File
4.5 Creating a WAR File with Ant
4.6 Creating a JAR File with Ant
4.7 Starting a Tomcat Application with Ant
4.8 Stopping a Tomcat Application with Ant5. Altering the Format of JSPs
5.1 Precompiling a JSP in Tomcat
5.2 Precompiling a JSP in WebLogic
5.3 Precompiling JSPs with the Precompilation Protocol
5.4 Mapping a JSP to Its Page Implementation Class
5.5 Creating a JSP from Scratch as a JSP Document
5.6 Generating an XML View from a JSP6. Dynamically Including Content in Servlets and JSPs
6.1 Including a Resource Each Time a Servlet Handles a Request
6.2 Using an External Configuration to Include a Resource in a Servlet
6.3 Including Resources Nested at Multiple Levels in a Servlet
6.4 Including a Resource that Seldom Changes into a JSP
6.5 Including Content in a JSP Each Time the JSP Handles a Request
6.6 Using an External Configuration File to Include a Resource in a JSP
6.7 Including an XML Fragment in a JSP Document
6.8 Including Content from Outside a Context in a JSP7. Handling Web Form Data in Servlets and JSPs
7.1 Handling a POST HTTP Request in a Servlet
7.2 Handling a POST HTTP Request in a JSP
7.3 Setting the Properties of a JavaBean in a JSP
7.4 Setting a Scoped Attribute in a JSP to the Value of a Form Parameter
7.5 Posting Data from a Servlet
7.6 Posting Data from a JSP
7.7 Using a Servlet to Add a Parameter to a Query String
7.8 Using a JSP to Add a Parameter to a Query String
7.9 Using a Filter to Read Parameter Values8. Uploading Files
8.1 Preparing the HTML Page for File Uploads
8.2 Using the com.oreilly.servlet Library
8.3 Uploading One File at a Time
8.4 Uploading Multiple Files
8.5 Renaming Files
8.6 Using a JSP to Handle a File Upload9. Handling Exceptions in Web Applications
9.1 Declaring Exception Handlers in web.xml
9.2 Creating an Exception-Handling Servlet
9.3 Sending an Error from a Servlet
9.4 Sending an Error from a JSP
9.5 Creating an Error-Handling JSP
9.6 Declaring a Special Exception-Handling JSP for Other JSPs10. Reading and Setting Cookies
10.1 Setting a Cookie with a Servlet
10.2 Creating an Array from All of the Request's Cookies
10.3 Setting a Cookie with a JSP
10.4 Reading Cookie Values with a Servlet
10.5 Reading Cookie Values with a JSP
10.6 Altering or Removing a Cookie That Has Already Been Set11. Session Tracking
11.1 Setting the Session Timeout in web.xml
11.2 Setting the Session Timeout in All Tomcat Web Applications
11.3 Setting the Session Timeout Programmatically
11.4 Checking if a Session Exists in an HttpServletRequest
11.5 Tracking Session Activity in Servlets
11.6 Tracking Session Activity in JSPs
11.7 Using URL Rewriting in a JSP
11.8 Using URL Rewriting in a Servlet
11.9 Using a Listener to Track the Session Lifecycle
11.10 Using a Listener to Monitor Session Attributes
11.11 Using a Filter to Monitor Session Attributes12. Integrating JavaScript with Servlets and JSPs
12.1 Including JavaScript Modules in a Servlet
12.2 Including JavaScript Modules in a JSP
12.3 Creating a New Window with JavaScript in a Servlet
12.4 Creating a New Window with JavaScript in a JSP
12.5 Using JavaScript to Validate Form Values in a Servlet
12.6 Using JavaScript to Validate Form Values in a JSP13. Sending Non-HTML Content
13.1 Sending a PDF File
13.2 Sending a Word Processing File
13.3 Sending an XML file
13.4 Sending an Audio File
13.5 Viewing Internal Resources in a Servlet14. Logging Messages from Servlets and JSPs
14.1 Logging Without Log4j
14.2 Setting Up Log4j
14.3 Using a Logger Without a Configuration File
14.4 Adding an Appender to the Root Logger
14.5 Using a Pattern with a Logger's Appender
14.6 Using log4j in a JSP
14.7 Logging Messages Using a Servlet Context Event Listener
14.8 Logging Messages Using a Session Event Listener15. Authenticating Clients
15.1 Creating Users and Passwords with Tomcat
15.2 Setting Up SSL on Tomcat
15.3 Using BASIC Authentication
15.4 Using Form-Based Authentication
15.5 Logging Out a User
15.6 Using JAAS to Create a LoginModule
15.7 Creating the JAAS Configuration File
15.8 Using JAAS in a Servlet
15.9 Using JAAS in a JSP16. Binding, Accessing, and Removing Attributes in Web Applications
16.1 Setting ServletContext Attributes in Servlets
16.2 Setting ServletContext Attributes in JSPs
16.3 Accessing or Removing ServletContext Attributes in Servlets
16.4 Accessing or Removing ServletContext Attributes in JSPs
16.5 Setting Session Attributes in Servlets
16.6 Setting Session Attributes in JSPs
16.7 Accessing or Removing Session Attributes in Servlets
16.8 Accessing or Removing Session Attributes in JSPs
16.9 Setting Request Attributes in Servlets
16.10 Setting Request Attributes in JSPs
16.11 Accessing or Removing Request Attributes in Servlets
16.12 Accessing or Removing Request Attributes in JSPs17. Embedding Multimedia in JSPs
17.1 Embedding an Applet in a JSP Using jsp:plugin
17.2 Embedding an Applet in a JSP Using the HTML Converter
17.3 Automatically Creating HTML Template for Including Flash Files
17.4 Writing HTML Template to Embed a Flash File
17.5 Embedding Flash in a Servlet
17.6 Embedding a QuickTime Movie in a JSP
17.7 Embedding an SVG File in a JSP
17.8 Embedding a Background Soundtrack in a JSP18. Working With the Client Request
18.1 Examining HTTP Request Headers in a Servlet
18.2 Examining HTTP Request Headers in a JSP
18.3 Using a Filter to Alter Request Headers
18.4 Automatically Refreshing a Servlet
18.5 Automatically Refreshing a JSP
18.6 Counting the Number of Web Application Requests19. Filtering Requests and Responses
19.1 Mapping a Filter to a Servlet
19.2 Mapping a Filter to a JSP
19.3 Mapping More Than One Filter to a Servlet
19.4 Changing the Order in Which Filters are Applied to Servlets
19.5 Configuring Initialization Parameters for a Filter
19.6 Optionally Blocking a Request with a Filter
19.7 Filtering the HTTP Response
19.8 Using Filters with RequestDispatcher Objects
19.9 Checking Form Parameters with a Filter
19.10 Blocking IP Addresses with a Filter20. Managing Email in Servlets and JSPs
20.1 Placing the Email-Related Classes on your Classpath
20.2 Sending Email from a Servlet
20.3 Sending Email from a Servlet Using a JavaBean
20.4 Accessing Email from a Servlet
20.5 Accessing Email from a Servlet Using a JavaBean
20.6 Handling Attachments from an Email Received in a Servlet
20.7 Adding Attachments to an Email in a Servlet
20.8 Reading a Received Email's Headers from a Servlet21. Accessing Databases
21.1 Accessing a Database from a Servlet Without DataSource
21.2 Configuring a DataSource in Tomcat
21.3 Using a DataSource in a Servlet with Tomcat
21.4 Creating a DataSource on WebLogic
21.5 Using a JNDI Lookup to get a DataSource from WebLogic
21.6 Using a DataSource from WebLogic in a JSP
21.7 Calling a Stored Procedure from a Servlet
21.8 Calling a Stored Procedure from a JSP
21.9 Converting a ResultSet to a Result Object
21.10 Executing Several SQL Statements Within a Single Transaction
21.11 Using Transactions with JSPs
21.12 Finding Information about a ResultSet22. Using Custom Tag Libraries
22.1 Creating a Classic Tag Handler
22.2 Creating a JSP 1.2 TLD for a Classic Tag Handler
22.3 Creating a JSP 2.0 TLD for a Classic Tag Handler
22.4 Packaging a Tag Library in a Web Application
22.5 Packaging the Tag Library in a JAR File
22.6 Using the Custom Tag in a JSP
22.7 Handling Exceptions in a Custom Tag Class
22.8 Creating a Simple Tag Handler
22.9 Creating a TLD for a Simple Tag Handler
22.10 Using a Simple Tag Handler in a JSP
22.11 Creating a JSP Tag File
22.12 Packaging the JSP Tag File in a Web Application
22.13 Packaging the JSP Tag File in a JAR
22.14 Using a Custom Tag Associated with a Tag File
22.15 Adding a Listener Class to a Tag Library23. Using the JSTL
23.1 Downloading the JSTL 1.0 and Using the JSTL Tags in JSPs
23.2 Downloading the Java Web Services Developer Pack
23.3 Using the Core JSTL Tags
23.4 Using the XML Core JSTL Tags
23.5 Using the XML Transform Tags
23.6 Using the Formatting JSTL Tags
23.7 Using A SQL JSTL Tag with a DataSource Configuration
23.8 Using A SQL JSTL Tag Without a DataSource Configuration
23.9 Accessing Scoped Variables with the EL
23.10 Accessing Request Parameters with the EL
23.11 Using the EL to Access Request Headers
23.12 Using the EL to Access One Request Header
23.13 Accessing Cookies with the EL
23.14 Using the EL to Access JavaBean Properties
23.15 Using JSTL Functions24. Internationalization
24.1 Detecting the Client Locale in a Servlet
24.2 Detecting the Client's Locales in a JSP
24.3 Creating a ResourceBundle as a Properties File
24.4 Creating a ResourceBundle as a Java Class
24.5 Using the ResourceBundle in a Servlet
24.6 Using the ResourceBundle in a JSP
24.7 Formatting Dates in a Servlet
24.8 Formatting Dates in a JSP
24.9 Formatting Currencies in a Servlet
24.10 Formatting Currencies in a JSP
24.11 Formatting Percentages in a Servlet
24.12 Formatting Percentages in a JSP
24.13 Setting the Localization Context in the Deployment Descriptor25. Using JNDI and Enterprise JavaBeans
25.1 Configuring a JNDI Object in Tomcat
25.2 Accessing the Tomcat JNDI Resource from a Servlet
25.3 Accessing the Tomcat JNDI Resource from a JSP
25.4 Configuring a JNDI Resource in WebLogic
25.5 Viewing the JNDI Tree in WebLogic
25.6 Accessing the WebLogic JNDI Resource from a Servlet
25.7 Accessing the WebLogic JNDI Resource from a JSP
25.8 Accessing an EJB Using the WebLogic JNDI Tree26. Harvesting Web Information
26.1 Parsing an HTML Page Using the javax.swing.text Subpackages
26.2 Using a Servlet to Harvest Web Data
26.3 Creating a JavaBean as a Web Page Parser
26.4 Using the Web Page Parsing JavaBean in a Servlet
26.5 Using the Web Page Parsing JavaBean in a JSP27. Using the Google and Amazon Web APIs
27.1 Getting Set Up with Google's Web API
27.2 Creating a JavaBean to Connect with Google
27.3 Using a Servlet to Connect with Google
27.4 Using a JSP to Connect with Google
27.5 Getting Set Up with Amazon's Web Services API
27.6 Creating a JavaBean to Connect with Amazon
27.7 Using a Servlet to Connect with Amazon
27.8 Using a JSP to Connect with AmazonIndex
商品描述(中文翻譯)
《Java Servlet 和 JSP 食譜》提供了數百個範例和數千行的程式碼,為任何使用 JavaServer Pages 或 Servlet 的 Java 網頁開發者提供了日常使用的技巧和技術,並提供了完整的解決方案來解決開發者在網頁應用程式開發中遇到的重大問題,這些解決方案可以直接插入到他們自己的應用程式中。《Java Servlet 和 JSP 食譜》呈現了現實世界中的問題,並為每個問題提供簡明且實用的解決方案。在這本全面的解決方案和最佳實踐的集合中,找到即使是一個經過測試的程式碼「食譜」,也能解決棘手的問題,將節省數小時的挫折,輕易地證明了這本寶貴書籍的價值。
但《Java Servlet 和 JSP 食譜》不僅僅是大量的剪貼程式碼。它還提供了清晰的解釋,說明程式碼如何運作及其原因,警告潛在的陷阱,並指引您尋找額外資訊的來源,讓您能學會將問題解決技術應用於類似情況。這些食譜涵蓋了重要主題,如使用 Ant 設置建置環境、WAR 檔案格式和 web.xml 部署描述符的廣泛介紹、檔案上傳、錯誤處理、Cookies、日誌記錄、處理非 HTML 內容、多媒體、請求過濾、網頁服務、國際化 (I18N)、網頁服務,以及其他許多讓即使是最資深的開發者也感到挫折的主題。
對於所有級別的 Java 網頁開發者來說,這本實用書中提供的解決方案將一再證明其無價之寶,特別是對於渴望將其他以 API 為重點的書籍中所呈現的理論付諸實踐的開發者。這是一種無痛的方式,讓經驗較少的開發者能夠通過實作來擴展他們的技能和生產力,同時解決他們每天面臨的緊迫問題。經驗更豐富的開發者可以利用這些食譜快速解決耗時的問題,從而騰出時間來專注於工作中更具創造性的方面。
目錄
前言
1. 撰寫 Servlets 和 JSPs
1.1 撰寫 Servlet
1.2 撰寫 JSP
1.3 編譯 Servlet
1.4 封裝 Servlets 和 JSPs
1.5 創建部署描述符
2. 部署 Servlets 和 JSPs
2.1 在 Tomcat 上部署單個 Servlet
2.2 在 Tomcat 的 server.xml 中使用 Context 元素
2.3 在 WebLogic 上部署單個 Servlet
2.4 在 Tomcat 上部署單個 JSP
2.5 在 WebLogic 上部署單個 JSP
2.6 在 Tomcat 上部署網頁應用程式
2.7 使用 Ant 在 WebLogic 上部署網頁應用程式
2.8 使用 WebLogic 管理控制台
2.9 使用 WebLogic Builder 部署網頁應用程式
2.10 使用 weblogic.Deployer 命令行工具
3. 命名您的 Servlets
3.1 在 web.xml 中將 Servlet 映射到名稱
3.2 為 Servlet 創建多個映射
3.3 為 Servlet 創建 JSP 類型的 URL
3.4 將靜態內容映射到 Servlet
3.5 在沒有 web.xml 映射的情況下調用 Servlet
3.6 將網頁應用程式中的所有請求映射到 Servlet
3.7 將請求映射到控制器並保留 Servlet 映射
3.8 為網頁應用程式創建歡迎檔案
3.9 限制某些 Servlets 的請求
3.10 只允許控制器訪問某些 Servlets
4. 使用 Apache Ant
4.1 獲取和設置 Ant
4.2 使用 Ant 目標
4.3 在建置檔案類路徑中包含 Tomcat JAR 檔案
4.4 使用 Ant 建置檔案編譯 Servlet
4.5 使用 Ant 創建 WAR 檔案
4.6 使用 Ant 創建 JAR 檔案
4.7 使用 Ant 啟動 Tomcat 應用程式
4.8 使用 Ant 停止 Tomcat 應用程式
5. 修改 JSP 的格式
5.1 在 Tomcat 中預編譯 JSP
5.2 在 WebLogic 中預編譯 JSP
5.3 使用預編譯協議預編譯 JSP
5.4 將 JSP 映射到其頁面實現類
5.5 從頭開始創建 JSP 作為 JSP 文件
5.6 從 JSP 生成 XML 視圖
6. 在 Servlets 和 JSPs 中動態包含內容
6.1 每次 Servlet 處理請求時包含資源
6.2 使用外部配置在 Servlet 中包含資源
6.3 在 Servlet 中包含多層嵌套的資源
6.4 將不常變更的資源包含到 JSP 中
6.5 每次 JSP 處理請求時包含內容
6.6 使用外部配置文件在 JSP 中包含資源
6.7 在 JSP 文件中包含 XML 片段
6.8 在 JSP 中從上下文外部包含內容
7. 在 Servlets 和 JSPs 中處理網頁表單數據
7.1 在 Servlet 中處理 POST HTTP 請求
7.2 在 JSP 中處理 POST HTTP 請求
7.3 在 JSP 中設置 JavaBean 的屬性
7.4 在 JSP 中將範圍屬性設置為表單參數的值
7.5 從 Servlet 發送數據
7.6 從 JSP 發送數據
7.7 使用 Servlet 向查詢字串添加參數
7.8 使用 JSP 向查詢字串添加參數
7.9 使用過濾器讀取參數值
8. 上傳檔案
8.1 為檔案上傳準備 HTML 頁面
8.2 使用 com.oreilly.servlet 庫
8.3 一次上傳一個檔案
8.4 上傳多個檔案
8.5 重新命名檔案
8.6 使用 JSP 處理檔案上傳
9. 在網頁應用程式中處理例外
9.1 在 web.xml 中聲明例外處理器
9.2 創建一個例外處理 Servlet
9.3 從 Servlet 發送錯誤
9.4 從 JSP 發送錯誤
9.5 創建一個錯誤處理 JSP
9.6 為其他 JSP 聲明一個特殊的例外處理 JSP
10. 讀取和設置 Cookies
10.1 使用 Servlet 設置 Cookie
10.2 從所有請求的 Cookies 創建數組
10.3 使用 JSP 設置 Cookie
10.4 使用 Servlet 讀取 Cookie 值
10.5 使用 JSP 讀取 Cookie 值
10.6 修改或刪除已設置的 Cookie
11. 會話追蹤
11.1 在 web.xml 中設置會話超時
11.2 在所有 Tomcat 網頁應用程式中設置會話超時
11.3 以程式方式設置會話超時
11.4 檢查 HttpServletRequest 中是否存在會話
11.5 在 Servlets 中追蹤會話活動
11.6 在 JSPs 中追蹤會話活動
11.7 在 JSP 中使用 URL 重寫
11.8 在 Servlet 中使用 URL 重寫
11.9 使用監聽器追蹤會話生命週期
11.10 使用監聽器監控會話屬性
11.11 使用過濾器監控會話屬性
12. 將 JavaScript 與 Servlets 和 JSPs 整合
12.1 在 Servlet 中包含 JavaScript 模組
12.2 在 JSP 中包含 JavaScript 模組
12.3 在 Servlet 中使用 JavaScript 創建新窗口
12.4 在 JSP 中使用 JavaScript 創建新窗口
12.5 使用 JavaScript 驗證 Servlet 中的表單值
12.6 使用 JavaScript 驗證 JSP 中的表單值
13. 發送非 HTML 內容
13.1 發送 PDF 檔案
13.2 發送文字處理檔案
13.3 發送 XML 檔案
13.4 發送音訊檔案
13.5 在 Servlet 中查看內部資源
14. 從 Servlets 和 JSPs 記錄訊息
14.1 無需 Log4j 進行日誌記錄
14.2 設置 Log4j
14.3 在沒有配置文件的情況下使用 Logger
14.4 向根 Logger 添加 Appender
14.5 使用 Logger 的 Appender 進行模式
14.6 在 JSP 中使用 log4j
14.7 使用 Servlet 上下文事件監聽器記錄訊息
14.8 使用會話事件監聽器記錄訊息
15. 驗證客戶端
15.1 使用 Tomcat 創建用戶和密碼
15.2 在 Tomcat 上設置 SSL
15.3 使用 BASIC 驗證
15.4 使用基於表單的驗證
15.5 登出用戶
15.6 使用 JAAS 創建 LoginModule
15.7 創建 JAAS 配置文件
15.8 在 Servlet 中使用 JAAS
15.9 在 JSP 中使用 JAAS
16. 在網頁應用程式中綁定、訪問和移除屬性
16.1 在 Servlets 中設置 ServletContext 屬性
16.2 在 JSPs 中設置 ServletContext 屬性
16.3 在 Servlets 中訪問或移除 ServletContext 屬性
16.4 在 JSPs 中訪問或移除 ServletContext 屬性
16.5 在 Servlets 中設置會話屬性
16.6 在 JSPs 中設置會話屬性
16.7 在 Servlets 中訪問或移除會話屬性
16.8 在 JSPs 中訪問或移除會話屬性