Results 1 to 6 of 6
  1. #1
    bala is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default Error 404 occurs while running Servlet

    Hai! I need your help!

    I have developed a servlet program using eclipse 3.6(helios) and apache tomcat 6.0.29. I got the error "Http Status 404-/ServletSample/us", "The requested resource(/ServletSample/us) is not available". What is the problem?
    Here is the servlet program code and web.xml code.
    My project name is "ServletSample".

    Java Code:
    package serv;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    public class Sample extends HttpServlet
    {
    	
    	public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException, ServletException
    
    	{
    		PrintWriter pw=res.getWriter();
    		pw.println("Welcome");
    		
    		
    	}
    }


    <?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>Hello</servlet-name>
    <servlet-class>serv.Sample</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/us</url-pattern>
    </servlet-mapping>
    </web-app>

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    As your error says resource is not found (404). Check the path you are referring is existing or not.

  3. #3
    bala is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default Java Servlet

    Hai! The path is correct. When i run a "index.jsp" file with the same project name, it executes. Only the servlet i cant able to run. please verify my code and web.xml file and reply me dude..

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    797
    Rep Power
    6

    Default

    /us is a mapping..But what is "ServletSample" here?

    Just give the complete link of how you are calling the servlet.
    Ramya:cool:

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by RamyaSivakanth View Post
    /us is a mapping..But what is "ServletSample" here?
    Yes, can you confirmed this?

  6. #6
    s2sgateway is offline Member
    Join Date
    Sep 2010
    Posts
    17
    Rep Power
    0

Similar Threads

  1. Odd error when running app
    By pahiker in forum New To Java
    Replies: 5
    Last Post: 06-23-2010, 03:10 PM
  2. Problem in running jasper report in servlet
    By khadaree in forum Java Servlet
    Replies: 1
    Last Post: 07-16-2009, 09:35 AM
  3. HTTP 404 Error while running Servlet Application
    By shuklajayb in forum Java Servlet
    Replies: 3
    Last Post: 06-24-2009, 05:19 PM
  4. Replies: 7
    Last Post: 01-30-2009, 06:40 AM
  5. Doubt in running the servlet
    By ramachandran in forum Java Servlet
    Replies: 0
    Last Post: 10-25-2007, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •