When is the contextInitialized() method of a ServletContextListener invoked?
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "When the web application is deployed or started.". ServletContextListener theo dõi vòng đời của ngữ cảnh ứng dụng: container tạo ServletContext khi nạp ứng dụng, phát sự kiện rồi gọi contextInitialized() trước khi bất kỳ servlet nào phục vụ yêu cầu, và gọi contextDestroyed() lúc tháo ứng dụng. Lựa chọn "After the web server receives an HTTP request." nhầm sang mức yêu cầu, nơi tương ứng là ServletRequestListener hoặc chính phương thức service(). Lựa chọn "When a new session is created for a client." ứng với HttpSessionListener và xảy ra nhiều lần, riêng cho từng người dùng. Lựa chọn "After the response is sent back to the client." cũng thuộc mức yêu cầu và còn ở cuối một lượt xử lý, trong khi contextInitialized() chỉ chạy đúng một lần ở đầu đời ứng dụng.
Cùng phần 11
Which method of the ServletContextListener interface is called when the ServletContext is initialized?Có lời giảiCâu hỏiWhich listener helps to monitor the changes in the values of session variables?Có lời giảiCâu hỏiWhich of the following events is typically handled by a ServletContextListener?Có lời giảiCâu hỏiCả 20 câu của chủ đề20 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây