Badr
Badr

Reputation: 10648

where to copy servlet files in apache tomcat server to work fine with web?

Can anyone guide me how to get Servlets working in Apache Tomcat server? I can run the Servlets from Netbeans without problems, but I don't know where to put the class files in Tomcat.

Upvotes: 2

Views: 6768

Answers (2)

Bozho
Bozho

Reputation: 597046

In tomcat:

  • class files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/classes
  • jar files must be in TOMCAT_DIR/webapps/<yourAppName>/WEB-INF/lib

(and if course you'll need web.xml in WEB-INF)

Upvotes: 4

BalusC
BalusC

Reputation: 1108682

They go in Tomcat/webapps folder. There are several ways to deploy a JSP/Servlet webapplication on Tomcat. They are all described in Tomcat Web Application Deployment HOW-TO.

If you already have developed the webapplication in Netbeans, then Netbeans should already have build a WAR file of it in the /dist folder. You just need to drop the WAR file in Tomcat/webapps folder and Tomcat will automatically deploy it during startup (or even while running, this is called hotdeploy).

If you want to develop without an IDE and/or don't want to create a WAR, then you just need to put a folder representing the context name in Tomcat/webapps, e.g. Tomcat/webapps/contextname. It will become the public web content. You can drop all JSP files and other static files in there. Then, for classes you need to create a Tomcat/webapps/contextname/WEB-INF/classes folder. There should go the package structure.

Upvotes: 1

Related Questions