Mega Code Archive

 
Categories / Java Tutorial / JSP
 

Get Parameter Name and Value from TreeMap

<%--   Copyright (c) 2002 by Phil Hanna   All rights reserved.      You may study, use, modify, and distribute this   software for any purpose provided that this   copyright notice appears in all copies.      This software is provided without warranty   either expressed or implied. --%> <%@ page import="java.util.*" %> <%    Enumeration eNames = request.getParameterNames();    if (eNames.hasMoreElements()) {       String title = "Parameters";       Map entries = new TreeMap();       while (eNames.hasMoreElements()) {          String name = (String) eNames.nextElement();          String[] values = request.getParameterValues(name);          if (values.length > 0) {             String value = values[0];             for (int i = 1; i < values.length; i++) {                value += "," + values[i];             }             entries.put(name, value);          }       }       request.setAttribute("_table_title", title);       request.setAttribute("_table_entries", entries);    } %>