Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

First Example Of HFServlets & JSP Not Working

 
Arthur Orange
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear List,

I am using Tomcat jakarta-tomcat-5.0.24 and I tried putting the example on page 30 into the webapp folder as directed on page 30 of HFEJB.

However whenever I type the url
http://localhost:8008/ch1/Serv1 I get :

HTTP Status 404 - /ch1/Serv1

------------------------------------

type Status report

message /ch1/Serv1

description The requested resource (/ch1/Serv1) is not available.


-----------------------

Apache Tomcat/5.0.24


Here is the thing, whenever I put the servlet class in the "servlets-examples" folder (that came with Tomcat) and then access the servlet with the class name specified I can access it fine and it works however I have been unable to make Tomcat recognize my web.xml file's descriptor settings which are :

<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/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>


My java code by the way works its just that Tomcat 5.0.24 is not picking up the web.xml file from the following path : C:\jakarta-tomcat-5.0.24\webapps\ch1\WEB-INF

Any ideas what could be the problem?

A
 
Arthur Orange
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arthur Orange:
Dear List,

I am using Tomcat jakarta-tomcat-5.0.24 and I tried putting the example on page 30 into the webapp folder as directed on page 30 of HFEJB.

However whenever I type the url
http://localhost:8008/ch1/Serv1 I get :

HTTP Status 404 - /ch1/Serv1



Any ideas what could be the problem?

A


By the way I used coreservlets's configuration tutorial and have the servlet invoker uncommented. I don't know if that is causing the problem.

It would be great if the source code was available with the book along with the preconfigured tomcat or j2ee appservers on the website. That would prevent me from wasting HOURS upon hours on simple examples that ought to work but don't because not all of us know the mysteries of some impossible container like tomcat (and ofcourse since its "FREE" its justifiable that hours of our lives be wasted away on this).

A
 
Arthur Orange
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked. I figured it out and this is the new web.xml file. I don't know what the difference is between the two but this version worked somehow:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>Head First Servlets Chapter 1 Servlet</display-name>
<description>
An application for testing servlets and JSP
</description>

<servlet>
<servlet-name>Example2</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>Example2</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>

</web-app>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic