The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes one question about init param Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "one question about init param" Watch "one question about init param" New topic
Author

one question about init param

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
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

Joined: Feb 27, 2002
Posts: 17
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

Joined: Mar 22, 2002
Posts: 208
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

Joined: Feb 27, 2002
Posts: 17
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

Joined: Feb 27, 2002
Posts: 17
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

Joined: Mar 22, 2002
Posts: 208
Thanks, guys for your advice. I figured it out. I think Marty's instructions are kind of misleading.
 
IntelliJ Java IDE
 
subject: one question about init param
 
Threads others viewed
Help!!! struts.action.MESSAGE error
Retrieving Database Username and Password
Running a servlet using Tomcat
How do i find out the relative path for my jar?
where to store the .htm files related to the servlet
IntelliJ Java IDE