I copied a HelloServlet application i got from the web and put it in the ROOT folder. I ran the server and it doesn't work. What is wrong? I think its about the location of the Java classes.
Compiling the servlet The servlet API jar file usually provided by the servlet container. In case of Tomcat 7.0, the jar file is placed under TOMCAT_HOME\lib directory and is named as servlet-api. jar.
By default, a servlet application is located at the path <Tomcat-installationdirectory>/webapps/ROOT and the class file would reside in <Tomcat-installationdirectory>/webapps/ROOT/WEB-INF/classes.
Where is it declared? So by default, the default servlet is loaded at webapp startup and directory listings are disabled and debugging is turned off. If you need to change the DefaultServlet settings for an application you can override the default configuration by re-defining the DefaultServlet in /WEB-INF/web. xml .
this documentation should help you
http://tomcat.apache.org/tomcat-7.0-doc/appdev/deployment.html
/WEB-INF/classes/ - This directory contains any Java class files (and associated resources) required for your application, including both servlet and non-servlet classes, that are not combined into JAR files. If your classes are organized into Java packages, you must reflect this in the directory hierarchy under /WEB-INF/classes/. For example, a Java class named com.mycompany.mypackage.MyServlet would need to be stored in a file named /WEB-INF/classes/com/mycompany/mypackage/MyServlet.class.
you have to put the web application in webapp folder in tomcat.
Also the url should be
http://localhost:8080/folder_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With