WebObjects J2EE Programming Guide- P1

JavaServer Pages (JSP) và servlets là những phần quan trọng của J2EE của Sun (Java 2 Platform, Enterprise Edition) kiến trúc. JSP là một đặc tả định nghĩa giao diện rằng các nhà cung cấp container servlet-có thể thực hiện để cung cấp các nhà phát triển khả năng tạo ra các trang Web năng động, mà là những tập tin với phần mở rộng. jsp. Servlet container giải thích những tập tin này và tạo servlets (còn được biết như servlets Workhorse) để xử lý các yêu cầu HTTP và tạo ra phản ứng. Servlets là server plug-in mà mở. | CHAPTER 2 JavaServer Pages The FavoriteFood component contains two attributes visitorName and favoriteFood. When the DiningWell workhorse servlet receives a request it passes two strings to the FavoriteFood component. The FavoriteFood component then uses those strings to render its HTML code. 1. Using a text editor create a file with the following contents -- -- @ taglib uri WOtaglib prefix wo HTML HEAD TITLE What to eat TITLE HEAD BODY wo component className Hello P P wo component className FavoriteFood bodyContentOnly true wo binding key visitorName value Worf wo binding key favoriteFood value gagh wo component BODY HTML Note that in this case the bodyContentOnly attribute of the wo component element is set to true this is the default so you don t need to specify a value for it . This allows you to define the FavoriteFood component as Full document the default setting in WebObjects Builder instead of Partial document. This way the component can be viewed as a Web page on its own and as a component within a JSP page. For faster processing you can set the bodyContentOnly attribute to false if you are certain that the component includes only the BODY element and not the HTML element. 2. Save the file as in JSP_Example Servlet Resources jsp. 3. In Project Builder create a component called FavoriteFood make sure you assign it to the Application Server target . 23 Passing Data From a JSP Page to a Component Legacy Document 2005-08-11 2002 2005 Apple Computer Inc. All Rights Reserved. CHAPTER 2 JavaServer Pages 4. Edit the component using WebObjects Builder so that it looks like Figure 2-3. Make sure to add accessor methods to the visitorName and favoriteFood String keys. Also ensure that the FavoriteFood component is set to Full document Figure 2-3 JSP_Example project the DiningWell component When you re done should look like Listing 2-1. Listing 2-1 import . import .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.