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 probl开发者_如何学Pythonems, but I don't know where to put the class files in Tomcat.
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
)
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.
精彩评论