Hi, I need to run my servlet program through tomcat.I dont know where to put the servlet.java file in tomcat directory.I am working in linux.I have installed apache-tomcat-5.5.26 in /usr/local.I have set the classpath in etc/profile as export CLASSPATH=$CLASSPATH:/usr/local/apache-tomcat-5.5.26/common/lib/servlet-api.jar. After this where should i put my servlet.java .I dont know the procedures.please anyone assist me.
Is servlet.java the source to a servlet? If so, you need to compile it first, and then place the class file into the WEB-INF/classes directory of your web application. Your web application would typically consist of a directory underneath the "webapps" directory in the main Tomcat installation directory.
An introduction to servlets, JSPs and Tomcat can be found here. [ March 29, 2008: Message edited by: Ulf Dittmer ]
Yes, your source file can be anywhere (including nowhere). Tomcat doesn't do anything with your Java source files.
You need to create a folder for your application under tomcat/webapps. You can name it anything you like (say 'myApp' for this discussion). Inside that folder, you need another one named WEB-INF (case sensitive). Inside WEB-INF, you need to create a folder named 'classes'. The classes directory is where your package directory structure goes. You class files go in the proper package folders.
A real quick way to get a sample, 'Hello, World' application with a proper directory structure and deployment descriptor up and running is to download our SimpleServlet.war example to your webapps directory. Tomcat will unpack this war file and deploy the application for you.
Thank you for providing that link. Unfortunately, it is not exactly correct. There are several directories listed that do not conform with the servlet spec and wouldn't work in a default Tomcat install (WEB-INF/help, WEB-INF/logs, etc).
It could be that those directories are specific to a particular application or project.
Unfortunately, it is not exactly correct. There are several directories listed that do not conform with the servlet spec and wouldn't work in a default Tomcat install (WEB-INF/help, WEB-INF/logs, etc).
Thanks Ben, to point me (Servlet spec) for the right track.