• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one question about init param

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys:
In order to get initialization parameters, we need to create a set-up file named web.xml. I am wondering where to put this file. Marty Hall says we should put it in install_dir/webpages/WEB-INF directory. But my Tomcat does not have this directory except one named "webapps". So, I created one and put web.xml there. But i still could not get init values from this setup file.
What should I do? Thx.
 
Clark Bruce
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick,
The web.xml file is the Deployment Descriptor file for the web application. It does reside in the WEB-INF (all caps) directory of your application. The init parameters are set up using the <init-param><param-name><param-value> and matching closing tags under the <servlet> element. I hope this helps. See page 42 of Marty Hall's Core Servlets and JavaServer Pages book for a better look at this file.
Regards,
Clark
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Clark Bruce:
Rick,
The web.xml file is the Deployment Descriptor file for the web application. It does reside in the WEB-INF (all caps) directory of your application. The init parameters are set up using the <init-param><param-name><param-value> and matching closing tags under the <servlet> element. I hope this helps. See page 42 of Marty Hall's Core Servlets and JavaServer Pages book for a better look at this file.
Regards,
Clark


Thanks Clark. I did follow Marty Hall's instructions. I created a subdirectory "webpages\WEB-INF" under my install_dir (which is the deployment area), and I put web.xml there. But it did not work, I also tried to put it under install_dir\webapps\WEB-INF, it did not work either. My .xml file is fine, I think something is wrong with the location where I put it. Tomcat on my machine does not have a default webpages subdirectory, I just created one. Maybe this is the problem?
Can anyone who tried this give some more insigts?
BTW, I used "http://localhost/servlet/MyServlet" to load the page, MyServlet is the servlet name I created.
 
Clark Bruce
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick,
Try placing the web.xml file in install_dir/webapps/Root/WEB-INF and placing your servlet class file in install_dir/webapps/Root/WEB-INF/classes
That works for me in TomCat 4.0. Hope this helps.
Regards,
Clark
 
Clark Bruce
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick,
Also, make sure that you stop and restart Tomcat after you make any changes to the web.xml file.
Regards,
Clark
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, guys for your advice. I figured it out. I think Marty's instructions are kind of misleading.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic