jspGet the value of the multi frame component
1.First, write a foreground page with multiple boxes.
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="request2.jsp" method="post"> 11 Favorite color: < br/>12 Red: < input type= "checkbox" name= "color" value= "red" />13 Green: < input type= "checkbox" name= "color" value= "green" />14 Blue: < input type= "checkbox" name= "color" value= "blue" />15 <hr/> 16 <input type="submit" /> 17 </form> 18 </body> 19 </html>
2.Write a processing page to get the value of the multi select 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[] color = request.getParameterValues("color"); 13 %> 14 Your favorite color15 <% 16 for(String c : color){ 17 out.println(c + " "); 18 } 19 %> 20 </body> 21 </html>