• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

running a servlet from a new web application

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
i'm trying to run a servlet from my own web application
but its giving me following error

HTTP Status 404 - /myLearning/servlet/HelloServlet

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

type Status report

message /myLearning/servlet/HelloServlet

description The requested resource (/myLearning/servlet/HelloServlet) is not available

i'm giving the following path
http://localhost:8080/myLearning/servlet/HelloServlet

and my class file for servlet is placed in this dir structure
E:\gaurav\j2ee\apache-tomcat-5.5.20\webapps\myLearning\WEB-INF\classes

i've made the corresponding enteries in web.xml file placed here
E:\gaurav\j2ee\apache-tomcat-5.5.20\webapps\myLearning\WEB-INF

and the file is:
<?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 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<display-name>myLearning</display-name>
<description>
myLearning
</description>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
</web-app>


but if i put my class file in ROOT structure
E:\gaurav\j2ee\apache-tomcat-5.5.20\webapps\ROOT\WEB-INF\classes
and make the corresponding enteries in web.xml file, it runs fine

i'm not able to figure out whats going wrong.

please reply.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am guessing you are using an old text or tutorial that depends on the dreaded Invoker servlet being configured on your system.

Your web.xml shows that your HelloServlet is not in a package - to avoid future hard to diagnose problems, put ALL classes involved in servlets or JSP in packages and place compiled class files accordingly.

Bill
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi the following link will give you instructions of how to config your TomCat server and running programs.. at the begining even i had same kind of problems i have followed those instructions and got my programming working try it


http://www.coreservlets.com/Apache-Tomcat-Tutorial/Tomcat-5.0-and-4.0.html
reply
    Bookmark Topic Watch Topic
  • New Topic