What are the possible causes for the HTTP Status 404 when running
servlets?
I am running Tomcat 4.1 with j2sdkee 1.3 and I am getting the error
below.
I am trying to run the example in "Java for the Web with Servlets,
JSP, and EJB" by Budi Kurniawan, pp. 11-12.
URL: http://localhost:8080/myApp/servlet/Testing
Error:
HTTP Status 404 - /myApp/servlet/Testing
--------------------------------------------------------------------------
type Status report
message /myApp/servlet/Testing
description The requested resource (/myApp/servlet/Testing) is not
available.
--------------------------------------------------------------------------
Apache Tomcat/4.1.18-LE-jdk14
--
This is a response from someone who tried to help. I added the mapping
as indicated with no success.
--
"Andy Flowers" <Andrew....@spamno.ntlworld.com> wrote in message news:<HQeW9.1255$Ts5....@newsfep4-win.server.ntli.net>...
> There appears to be no mapping for the /servlet/* path.
>
> Try adding a
>
> <filter-mapping>
> <filter-name>Path Mapped Filter</filter-name>
> <url-pattern>/servlet/*</url-pattern>
> </filter-mapping>
>
>
Thanks for your advice, but the mapping did not resolve the 404 error.
--
This is the web.xml file as it now stands:
<?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>
<servlet>
<servlet-name>Testing</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
<filter-mapping>
<filter-name>Path Mapped Filter</filter-name>
<url-pattern>/servlet/*</url-pattern>
</filter-mapping>
</web-app>
Is there a syntax error in it?
Also, this is my directory structure:
C:\Program Files\Apache Group\Tomcat 4.1\webapps\myApp\WEB-INF
C:\Program Files\Apache Group\Tomcat 4.1\webapps\myApp\WEB-INF\classes
Are the spaces in the path an issue?
BTW, I get these pages fine:
http://localhost:8080/index.jsp
http://localhost:8080/admin/login.jsp
http://localhost:8080/examples/servlets/index.html
http://localhost:8080/examples/servlet/HelloWorldExample
and so on. Something must be wrong in my application folder "myApp"
but I don't know what it could be.
Any help anyone can give would be greatly appreciated.
Thanks,
Shepherdmoon
The invoker servlet is disabled by default in Tomcat 4.1, so the
/myApp/servlet/ServletName URL won't work.
You can enable it, but it's not recommended. Instead, create <servlet> and
<servlet-mapping> tags in web.xml for each of your servlets.
--
Wendy in Chandler, AZ
Thanks!! I have spent hours here and there over a few weeks trying to
figure this out in my spare time and your suggestion did the trick. It
worked in getting the servlet going. (I wonder why the book example I
used does not include this additional code.) But there is one strange
thing I saw.
When I load http://localhost:8080/myApp/servlet/Testing in Netscape
7.0 and Communicator 4.8, though, I see this:
<HTML>
<HEAD>
<TITLE>Servlet Testing</TITLE>
</HEAD>
<BODY>
Welcome to the Servlet Testing Center.
</BODY>
</HTML>
That is, raw HTML source instead of the HTML page itself. The code
works OK in IE 6.0 and Opera 6.05, oddly enough.
I am going to try a few things to resolve this, but if you happen to
know the answer for why this doesn't run in Netscape 7.0, I would be
most grateful if you could post it here. Also, how does one know if
the default invoker servlet is in fact disabled? I see several
invokers in the web.xml file in the examples directory and they are
not commented out. (I am new to this so perhaps there is an invoker
servlet somewhere else that is disabled.)
Thanks again for any additional help you can give.
Regards,
Shepherdmoon
"Instead, create <servlet> and <servlet-mapping> tags in web.xml for
each of your servlets."
For every servlet in the app? Or can you specify a path (folder)
where all of your servlets are?
shephe...@yahoo.com (Shepherd Moon) wrote in message news:<cf4333c3.03020...@posting.google.com>...