Bài giảng Công nghệ Java: Bài 2.1 - Nguyễn Hữu Thể

Bài giảng Công nghệ Java - Bài : Servlet. Nội dung trình bày trong bài giảng này gồm có: Servlet and architecture, Interface Servlet and the Servlet Life Cycle, HttpServlet Class, HttpServletRequest Interface, HttpServletResponse Interface, Project Servlet in Eclipse, HTTP get Requests, HTTP get requests containing data, HTTP post requests, redirecting requests to other resources, welcome files. | Bài giảng Công nghệ Java: Bài - Nguyễn Hữu Thể CÔNG NGHỆ JAVA Nguyễn Hữu Thể Bài 2: Servlet 1 Nội dung ▪ Servlet and Architecture ▪ Interface Servlet and the Servlet Life Cycle ▪ HttpServlet Class ▪ HttpServletRequest Interface ▪ HttpServletResponse Interface ▪ Project Servlet in Eclipse ▪ HTTP get Requests ▪ HTTP get Requests Containing Data ▪ HTTP post Requests ▪ Redirecting Requests to Other Resources ▪ Welcome Files 2 Servlet and Architecture − Servlets: chạy trên Web server hoặc Application server. − Tầng trung gian giữa HTTP Client với các Database hoặc các ứng dụng trên HTTP server. − Ưu điểm Servlets: ▪ Hiệu năng tốt. Tính bảo mật cao (dựa trên Java). Độc lập trên nền tảng. ▪ Thư viện Java, giao tiếp với Applet, Database hoặc phần mềm khác. 3 Servlet Package − Java Servlets sử dụng các lớp Java => Run bởi Web Server. − Các gói thư viện hỗ trợ: ▪ ▪ − Servlet được biên dịch giống như các lớp khác trong Java. − Các interface và các lớp trong API Servlet ▪ Servlet, ▪ GenericServlet, ▪ HttpServlet, ▪ ServletRequest, ▪ ServletResponse, 4 Servlet Life Cycle 1. Servlet được khởi tạo bằng cách gọi phương thức init() 2. Phương thức service() được gọi để xử lý yêu cầu của client. 3. Servlet được hủy bằng phương thức destroy() 4. Cuối cùng, servlet được thu thập bởi bộ sưu tập rác của JVM. 5 Interface Servlet Method Description initializes the servlet. It is the life cycle method of servlet and public void init(ServletConfig config) invoked by the web container only once. provides response for the incoming public void service(ServletRequest request. It is invoked at each request,ServletResponse response) request by the web container. is invoked only once and indicates public void destroy() that servlet is being destroyed. public ServletConfig getServletConfig() returns the object of ServletConfig. returns information about servlet public

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
10    465    2    27-04-2024
Đã 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.