Chris Crawford wrote:But then I plunged into the Servlet stuff, poring over several books, looking at numerous examples, reading the problems that people were talking about on fora like this. It's much more complicated than Sockets. So I'd like to ask the wise old men here: what would be the best overall sequence of learning steps for me to perform? In particular, should I try to set up a LAN server and do my servlet experiments here at home? Or is that no easier than doing it through the ISP who hosts my website?
Another problem: how do I figure out how to install my servlets on my website? Everything I read says, "Consult your ISP for directions on how to do this." My ISP is Network Solutions, which seems to have some sort of world's record for impenetrable support documentation. They have thousands of pages of documentation, but when I search for "servlet", I get just three hits, none of them relevant. A search for "install servlet" yields zero hits. Same with "Tomcat", even though their sales documentation says that it's part of my service contract. Should I dump these idiots for another ISP, or are they all designed for IT managers from Microsoft?
I have another monkey wrench to toss in: I work on Macintosh, OS 10.7. 5, using Eclipse IDE. Every single web source I have found shows how to do things with command-line entries. Is there no way to do this kind of work in the Macintosh environment, using Eclipse and an FTP program?
Lastly, is this topic of so much complexity that I really should buy a book dedicated to servlet programming and read it cover to cover before proceeding further?
Make sure that your servlet class is in a package other than the default. This is not optional. As of JDK 1.4, classes in the default package cannot be imported and it can cause issues with deploying the servlet. Package your servlet class! In fact, package all of your classes -- it's a good practice.
Make sure that the servlet class is properly placed under the WEB-INF/classes hierarchy, or properly packaged in a jar file in WEB-INF/lib.
Make sure that the servlet is properly declared in the deployment descriptor.
Make sure that there is a servlet mapping for the servlet in the deployment descriptor.
Make sure that the URL that you are using starts with the context path of the web application, which should be followed by the servlet mapping. For example: "/context-path/servlet-path". Using page-relative addressing in an anchor tag, or as a form action, is almost guaranteed to cause issues. Even if you can get it to work, it is fragile and can break with the least little of changes.
So I'd like to ask the wise old men here:
BTW, this line is included in my source code:
I'm inclined to get the Head First book on servlets; I loved the Head First book on Java.
It is never advisable to copy the jar files out of Tomcat. That way lies heartbreak and misery. Always use the jar files in place.
Bear Bibeault wrote:Are you running Tomcat standalone, or inside eclipse? If the latter, I likely can't be of much help.
Have you checked Tomcat's manager application to see if the context is even deployed?