Bài giảng Lập trình Java nâng cao: Bài 2.1 - Nguyễn Hữu Thể

Bài giảng Lập trình Java nâng cao: Bài 2 - Servlet cung cấp cho các bạn kiến thức tổng quan về Servlet init(); ; Annotation; Forward và Redirect. Để hiểu rõ hơn, mời các bạn tham khảo chi tiết nội dung bài giảng này. | CÔNG NGHỆ JAVA Nguyễn Hữu Thể Bài 2 Servlet 1 Nội dung Servlet init Annotation Forward Redirect 2 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 String getServletInfo such as writer copyright version etc. 3 package public class InitParamServlet extends HttpServlet VD private static final long serialVersionUID 1L init Khởi tạo giá trị cho private String email email public InitParamServlet doGet Khởi tạo giá trị cho @Override email2 public void init ServletConfig config throws ServletException config Lấy giá trị của tham số khởi tạo. Cấu hình trong . quot email1 quot @Override protected void doGet HttpServletRequest request HttpServletResponse response throws ServletException IOException Lấy giá trị của tham số khởi tạo theo một cách khác. String email2 .getInitParameter quot email2 quot ServletOutputStream out quot quot quot quot quot Init Param quot quot email1 quot quot quot quot email2 quot email2 quot quot quot quot quot quot 4 JavaTech_Servlet Thiết lập thông tin cấu hình initParamServlet email1 abc@ email2 def@ initParamServlet initParam 5 Sử dụng Annotation trong Servlet @WebServlet To declare a servlet. @WebInitParam

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
Đã 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.