//display the parameter names and values
Enumeration paramNames = request.getParameterNames();
String parName;//this will hold the name of the parameter from the HTML form
boolean emptyEnum = false;
if (! paramNames.hasMoreElements())
emptyEnum = true;
//set the MIME type of the response, "text/html"
response.setContentType("text/html");
//use a PrintWriter send text data to the client who has requested the servlet
java.io.PrintWriter out = response.getWriter();
//Begin assembling the HTML content
out.println("<html><head>");
out.println("<title>Submitted Parameters</title></head><body>");
if (emptyEnum){
out.println("<h2>Sorry, the request does not contain any parameters</h2>");
} else {
out.println("<h2>Here are the submitted parameter values</h2>");
}
while(paramNames.hasMoreElements()){
parName = (String) paramNames.nextElement();
out.println("<strong>" + parName + "</strong> : " + request.getParameter(parName));
out.println("<br />");
}//while
out.println("</body></html>");