URL sau truyền 2 giá trị cho chương trình HelloForm dùng phương thức GET:
href="https://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI"
Chương trình JSP main.jsp xử lý đầu vào. Dùng phương thức getParameter() để dễ dàng truy cập thông tin:
<html>
<head> <title>Using GET Method to Read Form Data</title> </head>
<body>
<h1>Using GET Method to Read Form Data</h1>
<ul>
<li><p><b>First Name:</b> <%= request.getParameter("first_name")%> </p></li>
<li><p><b>Last Name:</b> <%= request.getParameter("last_name")%> </p></li>
</ul>
</body>
</html>
Gõ href="https://localhost:8080/main.jsp?first_name=ZARA&last_name=ALI" vào thanh địa chỉ trình duyệt. Kết quả:
Using GET Method to Read Form Data
|