I compile my first servlet and try to use tomcat. but get really tired on sintalling the servlet. I got two version tomcat : 3.4 and the latest one 5.5.4 . both server can run very well. As my ebook using the old tomcat 3.o as the sample. I just want to know where shall I put my .class files and then I can test them by putting url like http://localhost/servlet/**
Tomcat comes with extensive documentation - if you can get Tomcat examples to run, you can read everything you need to know by picking the right links from the startup page. Start at http://localhost/tomcat-docs/index.html Bill
it seems tomcat changed a lot from version 3.0, my ebook is based on tomcat 3.0 and I can not follow the way to just put a .class file to some dir like installdir/webpages/WEB-INF/classes. and then, just use http://localhost/servlet/** to test that servlet. as I am very new on tomcat and servlet , so, normally , how to test your servlet and jsp file in tomcat then. I run the example and I notice the structure of a .war is quite complex in some way.
They're not complex. You just need to have a WEB-INF directory in the base of the war. Put a copy of web.xml in that file. Your compiled and packaged servletes go in WEB-INF/classes and any java libraries (jar files) go in WEB-INF/lib.
Go to http://simple.souther.us and grab SimpleServlet.war. Put it in the webapps directory of Tomcat and it should run. Use that as a reference.
Author and all-around good cowpoke
Joined: Mar 22, 2000
The most confusing change from Tomcat 3 to the current 4 and 5 has to do with addressing your class with the /servlet/ URL. The Invoker servlet that permitted this simplified approach was on by default in Tomcat 3 but is now off. Now you have to either turn invoker on specifically or configure using the web.xml file. The invoker is described in more detail in this ranch FAQ. The idea with the invoker was to make it real easy to get your first servlet running, but the bad effect was that it prevented using the standard configuration method - which you would have to learn anyway. Bill
Joined: Nov 06, 2004
you know, I just pass the programmer certification last week. it seems that I can not test jsp and servlet in the same way that I test standard java applications. as they are treat as web application and need a web server to containing and supporting it. so, I can not just put raw code files. deployment steps need to be followed. also, I can just get an simple war file and change its setting to adapt my code then, test my code in this way, but it is not the way people work on it. am I right ? I am not a programmer before, but I believe I like it in some way. it took me one month and a half to pass the scjp. I don't know when I can pass this one. it seems more difficult . thank you guys, I know I can learn a lot here. your quick reply really give me confidence!!! Thank you..