jspGets the value of the drop-down component.
1.First, write a foreground page with a drop-down box.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 <form action="request3.jsp" method="post"> 11 The country < br/>12 <select name="country"> 13 <option value="China "> China < /option>";14 <option value="The United States ">"; the United States < /option>15 <option value="Russia's ">"; Russia's < /option>16 </select> 17 <br/> 18 <input type="submit" /> 19 </form> 20 </body> 21 </html>
2.Write a processing page to get the value of the drop-down component.
1 <%@ page language="java" contentType="text/html; charset=UTF-8" 2 pageEncoding="UTF-8"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 4 <html> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 7 <title>Insert title here</title> 8 </head> 9 <body> 10 <% 11 request.setCharacterEncoding("utf-8"); 12 String national = request.getParameter("country"); 13 out.println(national); 14 15 %> 16 </body> 17 </html>