jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes I hava some question about servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "I hava some question about servlet" Watch "I hava some question about servlet" New topic

I hava some question about servlet

quhao baggy

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: 196
Remember that a context-parm can be specified in the web.xml as follows :

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
subject: I hava some question about servlet
It's not a secret anymore!