permaculture playing cards*
The moose likes Servlets and the fly likes running a servlet from a new web application 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 "running a servlet from a new web application" Watch "running a servlet from a new web application" New topic
Author

running a servlet from a new web application

gaurav abbi
Ranch Hand

Joined: Jan 05, 2007
Posts: 108
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.


thanks,<br />gaurav abbi
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12674
    
    5
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


Java Resources at www.wbrogden.com
ashok ganesan
Ranch Hand

Joined: Jan 02, 2007
Posts: 50
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: running a servlet from a new web application
 
Similar Threads
servlet is not available
Error 404 while requesting for a page
JSTL not working
Web.XMl in JSP
Servlet Error