FileDocCategorySizeDatePackage
InitParams.javaAPI DocExample1588Wed Aug 15 23:52:58 BST 2001None

InitParams

public class InitParams extends HttpServlet
Show both ServletContext.getInitParameter and Servlet.getInitParameter! The following configuration info is for Tomcat and J2EE XML. N.B. The web.xml file MUST be that for the "web application", NOT the master one for Tomcat which lives in /etc/tomcat (or whereever). The ServletContext init parameters are set as context-param in web.xml as param-value> The Servlet's own init parameters are set in web.xml as .........

Fields Summary
protected String
CONTEXT_PARAM
protected String
CURR_DIR
protected String
SERVLET_PARAM
Constructors Summary
Methods Summary
public voidinit()


	     

		ServletConfig config = getServletConfig();
		ServletContext ctx = config.getServletContext();

		CONTEXT_PARAM = ctx.getInitParameter("myParm");
		CURR_DIR = getServletContext().getRealPath("/");
	
public voidservice(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


		SERVLET_PARAM = getInitParameter("myParm");
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<i>Hello</i>");
		out.println("<p>CONTEXT_PARAM = " + CONTEXT_PARAM);
		out.println("<p>SERVLET_PARAM = " + SERVLET_PARAM);
		out.println("<p>CURR_DIR = " + CURR_DIR);
		out.println("<h6>$Id: InitParams.java,v 1.3 2001/08/16 02:52:58 ian Exp $</h6>");