Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I hava some question about servlet

 
quhao baggy
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic