![Phân tích tư tưởng của nhân dân qua đoạn thơ: Những người vợ nhớ chồng… Những cuộc đời đã hóa sông núi ta trong Đất nước của Nguyễn Khoa Điềm](https://timtailieu.net/upload/document/136415/phan-tich-tu-tuong-cua-nhan-dan-qua-doan-tho-039-039-nhung-nguoi-vo-nho-chong-nhung-cuoc-doi-da-hoa-song-nui-ta-039-039-trong-dat-nuoc-cua-nguyen-khoa-136415.jpg)
WebObjects J2EE Programming Guide- P1
Số trang: 22
Loại file: pdf
Dung lượng: 408.48 KB
Lượt xem: 11
Lượt tải: 0
Xem trước 3 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
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ệnrằ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ở...
Nội dung trích xuất từ tài liệu:
WebObjects J2EE Programming Guide- P1CHAPTER 2JavaServer PagesThe FavoriteFood component contains two attributes: visitorName and favoriteFood. When the DiningWellworkhorse servlet receives a request, it passes two strings to the FavoriteFood component. The FavoriteFoodcomponent then uses those strings to render its HTML code.1. Using a text editor, create a file with the following contents: What to eat? 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 DiningWell.jsp 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).Passing Data From a JSP Page to a Component 23Legacy 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 FavoriteFood.java should look like Listing 2-1. Listing 2-1 FavoriteFood.java import com.webobjects.foundation.*; import com.webobjects.appserver.*; import com.webobjects.eocontrol.*; import com.webobjects.eoaccess.*; public class FavoriteFood extends WOComponent { protected String visitorName; protected String favoriteFood; public FavoriteFood(WOContext context) { super(context); } public String visitorName() { return visitorName; } public void setVisitorName(String newVisitorName) { visitorName = newVisitorName; } public String favoriteFood() { return favoriteFood;24 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 } public void setFavoriteFood(String newFavoriteFood) { favoriteFood = newFavoriteFood; } } 5. Build the project and restart your servlet container, if necessary. If you’re using Tomcat, you can view the new page in your browser with this URL http://localhost:8080/JSP_Example/jsp/DiningWell.jsp The Web page should look like Figure 2-4. Figure 2-4 JSP_Example project—the output of DiningWell.jsp This is the HTML code your Web browser receives (the listing is indented for easy reading): What to eat? Hello, World! Worfs favorite food is gagh. Using WebObjects Classes in a JSP Page This section continues work on the JSP_Example project. It explains how to write a JSP page that makes use of two WebObjects classes, NSArray and NSMutableArray, to pass information to a component called MusicGenres. Using WebObjects Classes in a JSP Page 25 Legacy Document | 2005-08-11 | © 2002, 2005 Apple Computer, Inc. All Rights Reserved. CHAPTER 2 JavaServer Pages 1. Using a text editor, create a file with the contents of Listing 2-2. Listing 2-2 InternetRadio.jsp file Music Available on Internet Radio Stations Note the invocation of the initStatics method of the WOServletAdaptor class. It performs the initialization of objects needed to integrate WebObjects with your servlet container (for example, adding a WOSession object to the JSPSession object). 2. Save the file as InternetRadio.jsp in the JSP_Example/Servlet Resources/jsp directory. 3. In Project Builder, create a component called MusicGenres (make sure you assign it to the Application Server target). 4. Add the genres and genre keys to MusicGenres using WebObjects Builder. genres is an array of Strings and genre is a String. Add a setter method for genres. Alternatively, you can add the following code to MusicGenres.java:26 Using WebObjects Classes in a JSP Page Legacy Document | 2005-08-11 | © 2002, 2005 Apple Computer, Inc. All Rights Reserved.CHAPTER 2JavaServer Pages protected String genre; /** @TypeInfo java.lang.String */ protected NSArray genres; public void setGenres(NSArray newGenres) { genres = newGenres; }5. Edit the component using We ...
Nội dung trích xuất từ tài liệu:
WebObjects J2EE Programming Guide- P1CHAPTER 2JavaServer PagesThe FavoriteFood component contains two attributes: visitorName and favoriteFood. When the DiningWellworkhorse servlet receives a request, it passes two strings to the FavoriteFood component. The FavoriteFoodcomponent then uses those strings to render its HTML code.1. Using a text editor, create a file with the following contents: What to eat? 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 DiningWell.jsp 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).Passing Data From a JSP Page to a Component 23Legacy 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 FavoriteFood.java should look like Listing 2-1. Listing 2-1 FavoriteFood.java import com.webobjects.foundation.*; import com.webobjects.appserver.*; import com.webobjects.eocontrol.*; import com.webobjects.eoaccess.*; public class FavoriteFood extends WOComponent { protected String visitorName; protected String favoriteFood; public FavoriteFood(WOContext context) { super(context); } public String visitorName() { return visitorName; } public void setVisitorName(String newVisitorName) { visitorName = newVisitorName; } public String favoriteFood() { return favoriteFood;24 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 } public void setFavoriteFood(String newFavoriteFood) { favoriteFood = newFavoriteFood; } } 5. Build the project and restart your servlet container, if necessary. If you’re using Tomcat, you can view the new page in your browser with this URL http://localhost:8080/JSP_Example/jsp/DiningWell.jsp The Web page should look like Figure 2-4. Figure 2-4 JSP_Example project—the output of DiningWell.jsp This is the HTML code your Web browser receives (the listing is indented for easy reading): What to eat? Hello, World! Worfs favorite food is gagh. Using WebObjects Classes in a JSP Page This section continues work on the JSP_Example project. It explains how to write a JSP page that makes use of two WebObjects classes, NSArray and NSMutableArray, to pass information to a component called MusicGenres. Using WebObjects Classes in a JSP Page 25 Legacy Document | 2005-08-11 | © 2002, 2005 Apple Computer, Inc. All Rights Reserved. CHAPTER 2 JavaServer Pages 1. Using a text editor, create a file with the contents of Listing 2-2. Listing 2-2 InternetRadio.jsp file Music Available on Internet Radio Stations Note the invocation of the initStatics method of the WOServletAdaptor class. It performs the initialization of objects needed to integrate WebObjects with your servlet container (for example, adding a WOSession object to the JSPSession object). 2. Save the file as InternetRadio.jsp in the JSP_Example/Servlet Resources/jsp directory. 3. In Project Builder, create a component called MusicGenres (make sure you assign it to the Application Server target). 4. Add the genres and genre keys to MusicGenres using WebObjects Builder. genres is an array of Strings and genre is a String. Add a setter method for genres. Alternatively, you can add the following code to MusicGenres.java:26 Using WebObjects Classes in a JSP Page Legacy Document | 2005-08-11 | © 2002, 2005 Apple Computer, Inc. All Rights Reserved.CHAPTER 2JavaServer Pages protected String genre; /** @TypeInfo java.lang.String */ protected NSArray genres; public void setGenres(NSArray newGenres) { genres = newGenres; }5. Edit the component using We ...
Tìm kiếm theo từ khóa liên quan:
thủ thuật máy tính công nghệ thông tin tin học quản trị mạng computer networkTài liệu liên quan:
-
52 trang 439 1 0
-
24 trang 366 1 0
-
Top 10 mẹo 'đơn giản nhưng hữu ích' trong nhiếp ảnh
11 trang 329 0 0 -
Làm việc với Read Only Domain Controllers
20 trang 321 0 0 -
74 trang 309 0 0
-
96 trang 305 0 0
-
Báo cáo thực tập thực tế: Nghiên cứu và xây dựng website bằng Wordpress
24 trang 299 0 0 -
Đồ án tốt nghiệp: Xây dựng ứng dụng di động android quản lý khách hàng cắt tóc
81 trang 291 0 0 -
Tài liệu dạy học môn Tin học trong chương trình đào tạo trình độ cao đẳng
348 trang 291 1 0 -
EBay - Internet và câu chuyện thần kỳ: Phần 1
143 trang 278 0 0