The WebServer I am using is Tomcat5.5.I compiled my Servlet program and now I want to run it. I took the .class file and put it in C:\tomcat\apache-tomcat-5.5.26\webapps\ROOT\WEB-INF\Classes folder and started my Tomcat server.
Now when I do this, http://localhost:8080/ it's taking me to the tomcat administration website or something. But when I do this, http://localhost:8080/servlet/HelloWorld I am getting an error as follows: HTTP Status 404 - /servlet/HelloWorld.
My questions are,
1).Am I doing anything wrong in running the servlet program?
2).Also, do we have to manually copy the .class file every time we compile our program to the tomcat classes folder?
3). How do I login to the Tomcat manager on http://localhost:8080/. It's asking me an Id and Pwd which I haven't choose at all. Is there a default Id and Pwd?
Instead of enabling the Invoker servlet (which was deprecated for the reasons listed in the link provided for by Christophe), why don't you create a mapping for your servlet?
If you want an example that's really quick and easy to get running, go to our CodeBarn and download the SimpleServlet war file. As soon as you drop it in your webapps directory, Tomcat will unpack and deploy it for you. Then, you will have a properly laid out web application with a deployment descriptor that has correct mappings.
I just have a few more questions. My current web.xml looks like this:
Should I be adding another <servlet> and <servlet-mapping> now? I tried adding the below part to what is already existing:
<servlet> <servlet-name>HelloWorld</servlet-name> HelloWorld is the java file name <servlet-class>Users.Ravi.Desktop.CurrentProject.Servlets.HelloWorld</servlet-class> </servlet> Here I gave the path to the place where the .class file is, this is not the path of the WEB-INF classes.
Where exactly is your HelloWorld.class file located on disk? Is it physically in the "..\Users\Ravi\Desktop\CurrentProject\Servlets" directory? If it's not actually within the your application's WEB-INF folder this is not going to work.
Joined: Nov 10, 2007
I put the HelloWorld.class file which was in C:\Users\Ravi\Desktop\CurrentProject\Servlets into
I just checked tho, there are some 9 WEB-INF folders in the TOMCAT folder and I wonder if ROOT\WEB-INF is the one in which I have to put the HelloWorld.class file and update the web.xml file in that directory.
I am sorry about that and I really cannot understand what you have said. I am a beginner so, If you don't mind, Can you please explain what you have said before?
Are you saying the HelloWorld.class file should be in C:\Tomcat\apache-tomcat-5.5.26\webapps\ROOT\WEB-INF\Classes. If so, Should I still be typing in http://localhost:8080/ROOT/hello in the browser? [ April 05, 2008: Message edited by: Arjun Reddy ]
hi arjun, you make new folder in webapps under that create WEB-INF/classes and put your web.xml file along with classes folder in web.xml you write your servlet mapping. under classes folder you put your .class files. suppose you have create hello folder in webappps and your url name is /Hello for your servlet then start the server and put localhost:8080/hello/Hello as url if you have not changed port number.