Good morning or evening wherever and whenever you maybe:
I am following the Chapter 2: Create Servlets (pp. 639 - 642) of the Java All-In-One Desk Reference for Dummies 2nd, where they are walking through the setup of the Installation and configuration of the Tomcat server. Within step 6 Modify the web.xml file to enable the invoker servlet. I am instructed to uncomment the block of code to enable the invoker. But when I do, and restart the server, the server won't start up. Plus I see the following Deprecated notice:
The bottom line is that without changing the configuration in the web.xml, any servlet which I build is not compiling a java file to a class file. Is this related issue because of the invoker or is it something different altogether? And more important what or where can I find a up to date tutorial for servlet and Jsp examples?
Well Ernest, thank you for being a friend and not letting me invoke without care. I woke up one morning after weeks of hard core Java concepts and review to the fact that everything is Web Based . . . SOA, JSP, Servlet, Flex/BlazeDS . . . WHERE HAVE BEEN (I say this jokingly of course), but I realized I can't data from point A to B anymore within embracing the NEW WEB INFRASTRUCTURE that I have been ignoring. The Web Server/Container is the new center of the universe.
Anyway, as I am working through the book, I assumed from the directions that as I was creating this servlet program seen here:
I assumed that the Web Container would compile the servlet code into the class file. I take I have this wrong. If I had a main method, then I could compile it in an IDE. . . no problem. But since I am in a Web Container, the container handle the main method operations in there own way I thought. Help as to what I missed.
BTW . . . Just read the Invoker Servlet FAQ. Makes sense.
author and iconoclast
You compile it in the IDE, and install the resulting "*.class" file(s) into the web container. Note that "compile" means to turn the Java files into *.class files -- you don't need a main() to compile anything. But you do need a main() to run your class as an application. The main() for a servlet is part of the web container (Tomcat) itself; you as a web developer never see it, nor do you need to.
Joined: Jun 24, 2008
Hmm . . . I poked around my eclipse IDE in thought think how to compile this program to a .class file. I guess I have only written and compiled java applications. I not sure would to do this in eclipse without a main method. Okay, mind is an open book (Reading too many book got me here in the first place . . . ). Cause you explain how to do this, please.
Okay I did compile the java file to a class at the command line. This I am sure is now the commercial way of compiling servlets . . . I hope.
author and iconoclast
Compiling from the command line works fine, but Eclipse is compiling your stuff behind the scenes as well. Depending on your project setup the class files are probably being put in a folder named "bin" inside your project that is invisible in the project navigator. Most people doing web development use some kind of web-server integration like the one provided by the WTP project. Then testing your servlet is a one-button process -- i.e., "Run As... | Web application". Highly recommended.