index.html
1 |
Servlet Config get multiple parameters
1 | <a href="get-all-servlet-config">Get All Servlet Config</a> |
web.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | <!--?xml version="1.0" encoding="UTF-8"?--> ServletConfigMulParam ebhor.servlet.ServletConfigMulParam PaymentMode Online Terms Handle with care. 30 days money back gaurantee Discount 20 percent Coupan GET20PERCENT ServletConfigMulParam /get-all-servlet-config 30 |
ServletConfigMulParam
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | package ebhor.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ServletConfigMulParam extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Enumeration params = getServletConfig().getInitParameterNames(); while (params.hasMoreElements()) { String param = params.nextElement(); String value = getServletConfig().getInitParameter(param); out.println(" |
“+param + “: ” + value+”<h2″); }=”” <=”” pre=””>
Result