protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Get all parameter name-value pairs MapparamMap = request.getParameterMap(); // Print out all parameters for (String paramName : paramMap.keySet()) { String[] values = paramMap.get(paramName); for (String value : values) { System.out.println(paramName + " = " + value); } } }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Get specific parameter values String name = request.getParameter("name"); String age = request.getParameter("age"); // Do something with the parameter values // ... }The library package for HttpServletRequest is javax.servlet.http.