전달인자 받기
String name = request.getParameterValue("name");
String name = request.getParameterValues("name")[0];
//form안에 있는 name, value 뒤의 전달인자를 순서대로 읽어와 브라우저에 출력한다.
Enumeration values = request.getParameterNames();
while (values.hasMoreElements()) {
String name = (String) values.nextElement();
String value = request.getParameterValues(name)[0];
if (name.compareTo("submit") != 0)
out.println(name +": " +value +"<br>");
}
--예제--
<FORM METHOD=POST ACTION="pr.jsp">
<INPUT TYPE="text" NAME="name" value="n1">
<INPUT TYPE="text" NAME="name" value="n2">
<INPUT TYPE="text" NAME="name" value="n3"><BR>
<INPUT TYPE="text" NAME="type" value="t1">
<INPUT TYPE="text" NAME="type" value="t2">
<INPUT TYPE="submit">
</FORM>
<%@ page import="java.util.*"%>
<%
Enumeration values = request.getParameterNames();
while (values.hasMoreElements()) {
String name = (String) values.nextElement();
for (int i=0;i<request.getParameterValues(name).length;i++) {
String value = request.getParameterValues(name)[i];
out.println(name +": " +value +"<br>");
}
}
%>