• Post Reply Bookmark Topic Watch Topic
  • New Topic

Head First Servlets & JSP Tomcat example  RSS feed

 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going through the Head First Servlets and JSP Tomacat book. On page 30,it shows how to create a servlet and load it into Tomcat. I've done what's in the book. When I chech my Tomcat manager, the /ch1 shows up under application/path but it is not started. I tried to start it and it says "FAIL - Application at context path /ch1 could not be started". Any help would be greatly appreciated.

Thanks,

Chuck
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose there is some compilation error with your program. If you are a beginner in java I would recommend you should learn java before Servlets.
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RSR, the compile went ok. It did take a while to figure out how to add the javax.servlet to the classpath. I received the Ch1Servlet.class file. I then moved it to my tomcat webapps directory under ch1/WEB-INF/classes and stopped and started tomcat. It won't start. This is my first servlet so I'm not sure what else I need to do.
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I dont know the exact program you are talking about but there could be errors in your web.xml. Can you paste it here within code tags?
 
Chuck Dial
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="ISO-8851-1" ?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>
</web-app>

The code is called web.xml under C:\Program Files\tomcat50-jwsdp\webapps\ch1\WEB-INF
The compiled class is at C:\Program Files\tomcat50-jwsdp\webapps\ch1\WEB-INF\classes\Ch1Servlet.class

Thanks.
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know, but it is probably worth reading the Servlets FAQ.
 
Shawn Montague
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your servlet class probably needs to be the full package name, ie:
com.mycompany.servlets.MyClassName

assuming here that you built the class in a package.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!