Java Server Pages: A Code-Intensive Premium Reference- P3

Java Server Pages: A Code-Intensive Premium Reference- P3:Before you begin reading Pure JSP Java Server Pages, you might want to take a look at its basic structure. This should help you outline your reading plan if you choose not to read the text from cover to cover. This introduction gives you an overview of what each chapter covers. | Process the HTTP Get request public void doGet HttpServletRequest request HttpServletResponse response throws ServletException lOException text html PrintWriter out html head title BasicServlet title head body Prints the REQUEST_METHOD sent by the client Your request method was n body html Process the HTTP Post request public void doPost HttpServletRequest request HttpServletResponse response throws ServletException lOException text html PrintWriter out html head title BasicServlet title head - 21 - body II Prints the REQUEST_METHOD sent by the client Your request method was n Ibody Ihtml IIGet Servlet information public String getServletInfo return BasicServlet Information The HTML Required to Invoke the Servlet This servlet implements both the doGet and the doPost methods. Therefore there are two ways to invoke this servlet. The first is to just reference the servlet by name in the URL. The following URL will execute the servlet on my local server http localhost servlet BasicServlet Using this method defaults the request method to get which will invoke the servlet s doGet method. The second way to invoke the servlet is to create an HTML page that will send a request to the servlet using the post method. This will invoke the servlet s doPost method. Listing shows the HTML listing to complete this task. Listing Displays the HTML Required to Invoke the Servlet Using the POST Method HTML HEAD TITLE BasicServlet ITITLE - 22 - HEAD BODY FORM ACTION http localhost servlet BasicServlet METHOD POST BR BR press Submit Query to launch servlet BasicServlet BR BR INPUT TYPE submit INPUT TYPE reset FORM BODY HTML When you invoke the servlet using either of these methods the results will be .

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
12    357    1    04-06-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.