I am finding trouble with the tomcat installations and running servlets on it. Here is what I have done... 1. Installed latest J2SE 5.0 update 6 on "D:\Java" 2. Installed latest version of Tomcat 5.5.12 on "D:\Tomcat\" 3. Set these variables as follows....
4. Unzipped the servlet classfiles in lib directory of "d:\java\lib"
After all this....
1. I type "javac" on the command line and it works fine. (Java environment variable is ok)
2. When I start the tomcat, the default page... http://localhost:8080/ is displayed. if I stop tomcat I am not able to view it. (Server is OK)
3. I am able to compile a servlet file.. HelloServlet.java and get a class file HelloServlet.class file (Servlets are compiled)
4. The examples that come bundled with "D:\Tomcat\webapps\servlets-examples" are working properly in Tomcat.
1. I created a new directory... by name "myAPP" in "D:\Tomcat\webapps" and I have... "D:\Tomcat\webapps\myAPP". Under this I created one more folder "WEB-INF\classes" and dumped my servlets there.
2. Copy pasted a "web.xml" with following contents in it...
And the servlet doesnt run in tomcat... ( This is the first step and I am bugged up with this, I know the preconfigured version at coreservlets.com works fine. But I want to configure things by myself. Moreover i can dump my servlets into "servlets-examples" folder itslef, but I want "myAPP" to run properly.... awaiting for your suggestions. Thanks in advance.
[ December 20, 2005: Message edited by: Akhil Trivedi ] [ December 20, 2005: Message edited by: Akhil Trivedi ]
There are multiple problems here: - JAVA_HOME must be exactly one directory, not several. In your case d:\java - CLASSPATH enumerates classes, but neither bin nor lib nor d:\java contains any. Jar files need to be specifically mentioned in the classpath in order to be picked up. - PATH is for executables. Ther are none in lib nor in d:\java nor in your web apps directory (I hope) Try to develop a solid understanding what PATH does and what CLASSPATH does.
The servlet mapping is not optional. It would be kind of unusual to map to *.do, though, because that's generally used by Struts, not straight servlets as you have here.
Thanks Ulf! I do understand the stuff... but do you think redundancy is gonna cause me problems. Well, i have taken off the unnecessary things here and i am still not out of my problem... servlets get compiled but dont run in a new folder... how do I configure my new folder and let tomcat accept it, without having to copy paste my class file and dump them in default "servlets-examples" folder??
Joined: Mar 22, 2005
What does "it doesn't run" mean? What happens when you hit http://localhost:8080/myApp/Hello (assuming you have mapped "Hello" to your servlet)? What do the <servlet> and <servlet-mapping> elements in your web.xml look like?
Joined: Nov 10, 2005
Originally posted by rathi ji:
It came by default in tomcat/common/lib directory.
[ December 20, 2005: Message edited by: rathi ji ]
you have to explicitly mention classpath
Joined: Jun 22, 2005
Here is the content of my web.xml fine that lies in.. "D:\Tomcat\webapps\myApp\WEB-INF" directory