This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I'm a beginer about servlet, I'm studying SCWCD there is a question I con't understand . There is method getInitParameter(name:String)in class "ServletContext" ,the book show that the parameter "name" is the element between <param-name> and </param-name> in a " *.xml " . I don't understand:How can the Instance of the class ServletContext find the "name"? And how can an Inatance of class ServletContext link to a " *.xml" ?Hown can it know which is the parameter it need? [ March 03, 2004: Message edited by: quhao baggy ]
Remember that a context-parm can be specified in the web.xml as follows : <web-app> .... <context-param> <param-name>question</param-name> <param-value>theAnswer</param-value> </context-param>
..... </web-app> This context parameter can be retrieved using : ServletContext httpServletContext = myHttpServlet.getServletContext(); String answer = httpServletContext .getInitParameter("question"); boolean b = "theAnswer".equals(answer); // true!!