wood burning stoves 2.0*
The moose likes Servlets and the fly likes Servlet 404 error 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 » Java » Servlets
Bookmark "Servlet 404 error" Watch "Servlet 404 error" New topic
Author

Servlet 404 error

lakshmanan anand
Greenhorn

Joined: Jan 13, 2009
Posts: 22
Hi,

I just got the book "Head first Servlets and JSP " book and i am implementing the example given in the first chapter.
I am using windows XP.

  • I wrote a servlet class and it compiled without errors.
  • I used classpath variable for servlet-api.jar to compile the class



  • I created the directory ch1 and put it inside the webapps directory under tomcat. My directory structure is ch1->WEB-INF->classes->Ch1Servlet.class

    my Deployment Desciptor (web.xml ) file is



    I typed http://localhost:8080/ch1/Serv1 as the URL. But still i get 404 error. Please help


    http://luckydev07.blogspot.com
    William Brogden
    Author and all-around good cowpoke
    Rancher

    Joined: Mar 22, 2000
    Posts: 12671
        
        5
    Your problem is due to the servlet class not being in a package.


    ALL classes used in servlets should be in a package and stored under classes according to the package.

    Older versions of Tomcat and older books depended on the "invoker" servlet to find classes not in a package - this was a very very very bad idea and was abandoned years ago. The original designers thought it would make things easier for beginners but it has caused untold trouble.

    See this ranch FAQ for the ugly details.

    Bill


    Java Resources at www.wbrogden.com
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Servlet 404 error
     
    Similar Threads
    404 Error
    Deployment Environment
    Tomcat - The requested resource is not available
    Cannot get Servlets Demystified Problem
    I am not able to Run Head First servlet example