Wrox Programmer Forums
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2005, 06:01 PM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

HTTP Status 404 - /myApp/servlet/TestingServlet

My 404 Status error was caused by insuffienct information in web.xml.
It requires two nodes, servlet and servlet-mapping, to work properly.


My folder structure looks like this:

/Tomcat 5.0/
--/webapps/
----/myApp/
------/WEB-INF/
--------web.xml
--------/classes/
----------TestingServlet.class


This is the web.xml that gave me success:


<?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>TestingServlet</servlet-name>
        <servlet-class>TestingServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>TestingServlet</servlet-name>
        <url-pattern>/servlet/TestingServlet</url-pattern>
    </servlet-mapping>
</web-app>
 
Old January 18th, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I dont understand why you have done this. I havent done this for a while, but as I remember you map a folder, all servlets placed in that folder should work, but you do not have a folder by the name TestServlet, if you rename the servlet so that it doesn not contain TestServlet in its name, does the mapping still work??



 
Old July 10th, 2005, 08:44 AM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi mbs31,

I had the same problem that u had(running the servlets using tomcat 5.59).
i could run the example servlets but i couldn't run my own servlets.
so i just uncommented the servlet and servlet mapping definitions in the /conf/web.xml files, but again it didnt work out

but amazingly when i restarted the server. it seemed to work.. dont ask me why.

so just try restarting the server after uncommenting those things in /conf/web.xml files. u might just consider restarting the browser as well.

well it worked for me.. may just work for u...

all the best.



 
Old July 11th, 2005, 09:10 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Web and Server XML are read by tomcat on startup, so any changes made require a re-start. If you are using classes within your web application, the addition of new methods also requires a restart to detect the changes.

 
Old July 1st, 2006, 12:19 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now, I have another problem with my first servlet in tomcat.
It works fine when i have no "package declaration" in my code.

But when i write this at the top of my code, it doesn't work anymore:
Code:
package sk.tomcatuser31.svlt;
The class that contains the servlet code is called "Rot31"
Code:
public class Rot13 extends HttpServlet { ....
I've added this in the web.xml, but appearently it seems not to work anymore.
Code:
<servlet>
<servlet-name>Rot13</servlet-name>
<servlet-class>sk.tomcatuser31.svlt.Rot13</servlet-class>
</servlet>

and

<servlet-mapping>
<servlet-name>Rot13</servlet-name>
<url-pattern>/servlet/Rot13</url-pattern>
</servlet-mapping>
when i leave out the package-things, it works :-(
what's wrong and where ?

 
Old July 5th, 2006, 02:55 PM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok got it.
i have to put the class file in a subdirectory structure of WEB-INF, like declared in the package.






Similar Threads
Thread Thread Starter Forum Replies Last Post
using tomcat as an application server deepak Apache Tomcat 0 July 27th, 2008 01:53 PM
executing a jsp program on tomcat server sushant2002 JSP Basics 2 August 28th, 2007 10:54 PM
Help with getting Tomcat to server php sazzie BOOK: Professional Apache Tomcat 0 March 16th, 2007 07:23 AM
how to register servlets with Tomcat 5.59 server urstruly90 Apache Tomcat 0 July 21st, 2005 03:50 AM
apache virtual server, mod_jk, tomcat 5 curiousmind Apache Tomcat 1 May 17th, 2005 09:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.