Java tutorial
import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class WebAppProperties extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); ServletContext context = getServletContext(); String displayName = context.getServletContextName(); if (displayName == null) { displayName = "(no display-name element defined)"; } out.println("<html>"); out.println("<head>"); out.println("<title>Web Application Properties"); out.println("</title>"); out.println("</head><body>"); out.println("<h1>Web Application Properties</h2>"); out.println("<br>Name: " + displayName); out.println("<br>Context: " + req.getContextPath()); out.println("<h2><center>"); out.println("Initialization Parameters</center></h2>"); out.println("<br>"); out.println("<center><table border width=80%>"); Enumeration e = context.getInitParameterNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); out.println("<tr>"); out.println("<td>" + name + "</td>"); out.println("<td>" + context.getInitParameter(name) + "</td>"); out.println("</tr>"); } out.println("</table></center>"); out.println("</body>"); out.println("</html>"); out.flush(); } }