aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes First Example Of HFServlets & JSP Not Working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "First Example Of HFServlets & JSP Not Working" Watch "First Example Of HFServlets & JSP Not Working" New topic
Author

First Example Of HFServlets & JSP Not Working

Arthur Orange
Ranch Hand

Joined: Dec 29, 2004
Posts: 30
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


SCJP, SCWCD, SCBCD, ICAD
Arthur Orange
Ranch Hand

Joined: Dec 29, 2004
Posts: 30
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

Joined: Dec 29, 2004
Posts: 30
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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: First Example Of HFServlets & JSP Not Working
 
Similar Threads
404 Error
I am not able to Run Head First servlet example
Cannot get Servlets Demystified Problem
HTTP Status 404 - /ch1/Serv1/
new to tomcat