Johny_M
Johny_M

Reputation: 641

Where do we put the Servlets in the directory structure of Tomcat?

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.

Upvotes: 8

Views: 8536

Answers (3)

Ivan Ivanov
Ivan Ivanov

Reputation: 23

You should put them in WEB-INF/classes . "This directory is for servlets, utility classes, and the Java compiler output directory"

Upvotes: 0

rxx
rxx

Reputation: 764

you have to put the web application in webapp folder in tomcat.

Also the url should be

http://localhost:8080/folder_name

Upvotes: 1

Aaron Saunders
Aaron Saunders

Reputation: 33345

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.

Upvotes: 3

Related Questions