Hi, I installed Tomcat 4.1.18 on both a ME & XP Home edition. The initial test page comes up fine, I have tested a few JSP's and they compile and work fine. All examples , JSP & Servlets work fine. however, when I put a simple servlet (like a Hello World type servlet) in the classes folder, and I access it with http://localhost:8080/servlet/HelloServlet I get a 404 message. I've been told to check out the capitalization and spelling of the directories. They check out fine...At this point this is getting real frustrating... I should add that I have no problem compiling the servlet and am moving the .class file into the classes directory Thanks for any help. [ July 23, 2003: Message edited by: john scott ]
I suspect that you havn't included your new servelts details in the web.xml document which I belive is in your web-inf directory. The way tomcat works in regards to servlets is that you have to place the servlet information in the web.xml document so it knows when to load that information. <servlet> <servlet-name>org.apache.jsp.index_jsp</servlet-name> <servlet-class>org.apache.jsp.index_jsp</servlet-class> </servlet> <servlet-mapping> <servlet-name>org.apache.jsp.index_jsp</servlet-name> <url-pattern>/index.jsp</url-pattern> </servlet-mapping> The url-pattern tells tomcat that if someone goes to www.yourdomain.com/index.jsp to load this serverlet.
1) You need to turn the servlet invoker on in the server.xml file. Details have been covered a few times in this forum. 2) You also need to put your classes in packages. Most containers have trouble finding classes in the default package. hth, bear
It should never be necessary to declare your .jsp files explicitly in web.xml the way Adam describes. Servlets yes, but JSPs no. The name of the class that the JSP compiles to is not something you should normally need to know, and I think it's container-dependent anyway. Servlets don't need to be in packages, but beans that are used in JSPs do need to be in packages. [ July 23, 2003: Message edited by: Ron Newman ]
As I recall, the invoker servlet can find servlets that are not in classes, but Tomcat has a problem otherwise - something about classes in the "default" package assumed to be in the "current" directory. The best policy is to always put servlets and helper classes in packages. Bill