TAILIEUCHUNG - Mastering Jakarta Struts phần 2

Độc giả, tuy nhiên, nên liên hệ với các công ty thích hợp cho biết thêm thông tin về thương hiệu và đăng ký. Bản quyền © 2002 bởi Wiley Publishing, Inc Tất cả các quyền. Được đăng bởi Wiley Publishing, Inc, Indianapolis, Indiana đã công bố đồng thời tại Canada. Không có phần nào của ấn phẩm này có thể được sao chép | The ServletContext HTML HEAD TITLE Context TITLE HEAD BODY Try to get the USERNAME attribute from the ServletContext String userName String USERNAME If there was no attribute USERNAME then create one and add it to the ServletContext if userName null Don t try to add it just say that you can t find it b Attribute USERNAME not found else b The current User is userName b BODY HTML Note In the Contextjsp we are using two JSP implicit objects the application object which references the ServletContext and the out object which references an output stream to the client. We will discuss each of these later in this chapter. Now copy to the CN7XL7W_HƠMỄ webapps wileyapp directory restart Tomcat and open your browser first to the following URL http localhost 8080 wileyapp You should see a page similar to Figure . Figure The output of the prior to the execution of the servlet ContextServlet. 21 Using Servlets to Retrieve HTTP Data You should notice that the Contextjsp cannot find a reference to the attribute USERNAME. It will not be able to find this reference until the reference is placed there by the ContextServlet. To do this open your browser to the following URL http localhost 8080 wileyapp servlet You should see output similar to Figure . Figure The output of the ContextServlet. After running this servlet the wileyapp Web application has an object bound to the name USERNAME stored in its ServletContext. To see how this affects another Web component in the wileyapp Web application open the previous URL that references the Contextjsp and look at the change in output. The JSP can now find the USERNAME and it prints this value to the response. Note To remove an object from the ServletContext you can restart the JSP servlet container or use the method. Using Servlets to Retrieve HTTP Data In this our final section on servlets

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.