Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Servlet

 
Richard Mendoza
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Tomcat 4.1 as the Web Server. I did the following procedures.
1. Under the webapps directory of Tomcat, I created a folder named myApps, this is the directory where all my java programs will be placed.
2. Under myApps directory, I created a directory named WEB-INF and inside WEB-INF, I created a directory named classes.
3. I created a servlet named SampleServlet.java, I saved it inside the classes directory compiled it producing no errors, thus SampleServlet.class has been created.
4. I run an Internet Explorer and inside the address box, I typed:
http://localhost:8080/myApps/servlet/SampleServlet
but, I am producing an error message. The message tells "unavailable" well in fact I checked on my servlet and it's on the right location.
I just followed the instructions that I found in a Java book.
Can anybody help me.... Thanks a lot!

Richard
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see this in your list, so I have to point it out - Make sure Tomcat is running! If you go into the bin directory there is a startup.bat file that you can use to start Tomcat. There is also a shutdown.bat you can use to stop Tomcat.

If Tomcat is running (and you just forgot to mention it) also go into the logs directory and make sure that your "myApps" web app context was started correctly. If there are any problems with your deployment descriptor (among other things), the web app (and any servlets in it) won't be loaded. Search through the logs and see if there are any errors preventing your web app from loading.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its the dreaded "invoker" servlet thing again. See this entry in the ranch FAQ.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic