| Author |
I hava some question about servlet
|
quhao baggy
Greenhorn
Joined: Dec 10, 2003
Posts: 5
|
|
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 ]
|
 |
Arnold Reuser
Ranch Hand
Joined: Nov 20, 2003
Posts: 193
|
|
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!!
|
 |
 |
|
|
subject: I hava some question about servlet
|
|
|