TAILIEUCHUNG - The j2eetm tutorial - phần 5

Lớp tạo ra và loại bỏ các trợ giúp cơ sở dữ liệu và các đối tượng truy cập được sử dụng trong ứng dụng sách của Duke. Các phương pháp lấy đối tượng bối cảnh web từ ServletContextEvent và sau đó lưu trữ (và loại bỏ) các đối tượng như là thuộc tính ngữ cảnh servlet. | Servlet Life Cycle 141 The class creates and removes the database helper and counter objects used in the Duke s Bookstore application. The methods retrieve the web context object from ServletContextEvent and then store and remove the objects as servlet context attributes. import import . import public final class ContextListener implements ServletContextListener private ServletContext context null public void contextInitialized ServletContextEvent event context try BookDB bookDB new BookDB bookDB bookDB catch Exception ex Couldn t create database Counter counter new Counter hitCounter counter Created hitCounter counter new Counter orderCounter counter Created orderCounter public void contextDestroyed ServletContextEvent event context BookDB bookDB bookDB bookDB hitCounter orderCounter Specifying Event Listener Classes You specify a listener class for a WAR in the deploytool Event Listeners inspector see Event Listeners page 126 . 142 Java Servlet Technology Handling Errors Any number of exceptions can occur when a servlet is executed. The web container will generate a default page containing the message A Servlet Exception Has Occurred when an exception occurs but you can also specify that the container should return a specific error page for a given exception. You specify error pages for a WAR in the deploytool File Ref s inspector Error Mapping page 126 . Sharing Information Web components like most objects usually work with other objects to accomplish their tasks. There are several ways they can do this. They can use private helper objects for example JavaBeans components they can share .

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.