I was a little embarrassed with myself when I discovered what went wrong with my NetBeans-TomCat-servlet application. My gosh! How could I have not known that?! Gosh, after years of teaching Web development.. Hehe.. It's really funny. But anyway, what matters is that I was able to realize my mistake. Handling too many subjects has left me with only an hour (mostly) to prepare for my subjects. I know it's not something to be proud of. And I'm really disappointed with myself because I wasn't able to foresee these problems when I accepted the subject load. Anyway, I just want to document this learning so I'll avoid committing the same mistake in the future.
I already installed TomCat 6.0 on my machine but I didn't start it from NetBeans. Instead, I opened my html file from where it was saved (somewhere in my local disk). Anybody who has had a background on Web development knows that you have to execute your html files from the server (ex. localhost) and not from where it is saved so that you could execute the scripts, or in this case, the servlet.
I was now confused why my html file could not "see" or locate my servlet. So I tried: removing and adding my TomCat server in NetBeans, and duplicating the servlet class in the different directories of TomCat. Nothing worked.
When I realized that I hadn't started TomCat from NetBeans, I tried to start it but now NetBeans would tell me that it failed to start TomCat because port 8080 is already in use. Argh!!! I searched the net for some answers and I learned that the error was due to multiple instances of TomCat that are running. I tried looking at the connections on my machine using netstat, and indeed, port 8080 was used. Whew!
I restarted my machine hoping that the service using 8080 would terminate. But, still I got the same freakin error! I was fed up and just tried using another port (8089) and when I started TomCat (inside NetBeans)... it worked!!! When I tried running the project, the browser was automatically invoked and the servlet did its job. Yey!!! Haha.
After all the confusion, my servlets are now running perfectly well.. :)