Java C11. Advanced Servlet

provide request information for HTTP servlets. The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).Client request information including : parameter name and values, and an input stream Attributes : custom information about a request. Extends the ServletRequest interface Returns the value of attribute : public Object getAttribute(String name) | Chapter 11. Advanced servlet ITSS Java Programming Dr. NGUYEN Hong Quang, FIT-HUT HttpServletRequest interface Outline provide request information for HTTP servlets. The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc). Request information Client request information including : parameter name and values, and an input stream Attributes : custom information about a request HttpServletRequest Interface Operating with attributes Extends the ServletRequest interface Returns the value of attribute : public Object getAttribute(String name) Stores an attribute in this request : public void setAttribute(String name, Object o) HttpServletRequest Interface Forwarding : cooperation between several Servlets Client Web browser Display reading page URL address Internet Application server Request Response Link in a Web page Servlet 1 Servlet 2 Servlet N Require parameters Proccessing data Connecting to database | Chapter 11. Advanced servlet ITSS Java Programming Dr. NGUYEN Hong Quang, FIT-HUT HttpServletRequest interface Outline provide request information for HTTP servlets. The servlet container creates an HttpServletRequest object and passes it as an argument to the servlet's service methods (doGet, doPost, etc). Request information Client request information including : parameter name and values, and an input stream Attributes : custom information about a request HttpServletRequest Interface Operating with attributes Extends the ServletRequest interface Returns the value of attribute : public Object getAttribute(String name) Stores an attribute in this request : public void setAttribute(String name, Object o) HttpServletRequest Interface Forwarding : cooperation between several Servlets Client Web browser Display reading page URL address Internet Application server Request Response Link in a Web page Servlet 1 Servlet 2 Servlet N Require parameters Proccessing data Connecting to database Forwarding : methods public RequestDispatcher getRequestDispatcher (String path) Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path public void forward (ServletRequest request, ServletResponse response) Forwards a request from a servlet to another resource (servlet, JSP file, or HTML file) on the server. Forwarding : usage example public void doGet ( HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // proccessing data // Get RequestDispatcher object RequestDispatcher rd = (“/servlet2”); // forwarding (req, res); } Application example helloPersonForward2 Servlet Display information Transmission of information helloPerson Forward2 Servlet Setting attributes + Name : input name + Date : access time (new information) Forward Test of forward servlets .

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
5    445    2    29-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.