Java examples for Servlet JSP:Servlet
get Request Map from HttpServletRequest
import javax.servlet.http.HttpServletRequest; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class Main{ //from ww w. j a v a 2 s. c om public static Map<String, String> getRequestMap( HttpServletRequest request) { Map<String, String> params = new HashMap<String, String>(); Enumeration<String> parameters = request.getParameterNames(); while (parameters.hasMoreElements()) { String key = parameters.nextElement(); String value = request.getParameter(key); value = value == null ? "" : value; params.put(key, value); } return params; } }