I got the html output. So I assumed tomcat is working fine.
Later I wrote a sample servlet class, by name Hello.java and successfully compiled it. Placed it in rootdir/webapps/root/first/WEB-INF/classes directory.
Later, I wrote the web.xml file and deployed it in
But it was not working and I got a requested resource not available error.
Is there anyway to debug my application. Everything seems to be right. This is driving me crazy.
Any input will be highly appreciated.
Thanks.
Bimal Patel
Ranch Hand
Joined: Aug 29, 2003
Posts: 130
posted
0
Hi,
I think root is something like a root application to Tomcat. If you put any page i.e. html/jsp in that directory or any other subdirectory of ROOT, it'll be accessible because no mapping is required. Please understand that you've not created a new web application by creating a directory under root. You have to have your directory under webapps and not under root i.e. at the same level as root.
You've also noticed that under root, there is a dir. called web-inf. So, root is a kind of web application and you need to create your own if you want to test anything. You can use root itself but then for deploying such servlets, you need to put the servlet classes under web-inf folder of ROOT and add the entries to the web.xml under that same.
I hope I've solved your problem!
Work Hard, Expect The Worst...<br /> <br />Bimal R. Patel<br />(SCJP 1.2, SCWCD 1.4)
stu ware
Greenhorn
Joined: Feb 04, 2006
Posts: 15
posted
0
But when I created a directory at the same level as roots under webapps,
Nothing is working. It is so frustrating . Is there any way to findout what is going wrong. I dont think the container is able to read the web.xml file.
Any help is highly appreciated.
stu ware
Greenhorn
Joined: Feb 04, 2006
Posts: 15
posted
0
Hi Bimal Patel,
Actually I was wrong. It worked when I placed my directory in webapps. I should have used webapps for my web application.
By the way, how to debug the servlets. Heard about log files. Where can I find them?
Any other techniques to debug......
Thanks for your help.
Bimal Patel
Ranch Hand
Joined: Aug 29, 2003
Posts: 130
posted
0
Hi,
Your welcome! I know such kind of troubls while you're in the initial stages of learning servlets/jsp and web application fundamentals.
For debugging servlets, you can do that by remote debugging with any of the IDEs available. I would strongly suggest Eclipse. It is totally free and you can find the help with remote debugging from net. Let me know if I can help much.
Hi Vasu I saw your directory structure but i come to the conclussion that your directory structure is wrong. Create the direcotory structure as i am writting. Please let me know if you have any issue.
Now in the web.xml make the entry as you specified in you post.: <web-app> <servlet> <servlet-name>HelloWorld</servlet-name> <servlet-class>Hello</servlet-class> </servlet>
you would definatly get the expected output, sure.
cheers, Chidanand Chauhan
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12267
1
posted
0
I know I sound like a broken record on this, but IMHO all classes used in servlets should be in a package. The directory structure under WEB-INF/classes must reflect the package structure. Not using a package can result in strange and hard to debug problems. Older servlet references may not emphasize this. See also the "invoker" servlet FAQ here at the ranch. Bill