FileDocCategorySizeDatePackage
InitParams.javaAPI DocExample1633Sat Aug 24 21:30:36 BST 2002None

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 ...... 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 = ctx.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.5 2002/08/25 01:30:36 ian Exp $</h6>");