Results 1 to 2 of 2
  1. #1
    Dayanand is offline Member
    Join Date
    Feb 2011
    Posts
    61
    Rep Power
    0

    Default how to run servlet

    HelloServlet.java
    package com.lara;

    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import java.io.PrintWriter;
    import java.io.IOException;
    import javax.servlet.ServletException;

    class HelloServlet extends HttpServlet
    {
    public void service(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    {
    PrintWriter out = res.getWriter();
    out.println("Hai Hai WELCOME MAN");
    out.close();
    }
    }
    i developed a class file by compiling the above HelloServlet.java in the same directory
    web.xml
    <web-app>
    <servlet>
    <servlet-name>hello</servlet-name>
    <servlet-class>
    com.lara.HelloServlet
    </servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>hello</servlet-name>
    <url-pattern>/callHello</url-pattern>
    </servlet-mapping>
    </web-app>


    web.xml is also in the same directory

    but when i type http://localhost:7070/app1/callHello in the IE browser,i got the below errors
    HTTP Status 404 - Servlet hello is not available
    type Status report
    message Servlet hello is not available
    description The requested resource (Servlet hello is not available) is not available.
    Apache Tomcat/5.5.28



    i kept HelloServlet.java,HelloServlet.class,web.xml inside webapps folder of tomcat5.5
    whats the mistake in done
    Thanks in advance
    Daya
    Last edited by Dayanand; 04-21-2011 at 08:34 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by Dayanand View Post
    ..

    i kept HelloServlet.java,HelloServlet.class,web.xml inside webapps folder of tomcat5.5..
    Why did you put those files there?
    Read a tutorial that explains how to correctly package a war file so that you don't have to guess as to what goes where.

Similar Threads

  1. how can i link html+servlet+xml to form servlet
    By balachandarr in forum Java Servlet
    Replies: 0
    Last Post: 04-15-2009, 04:06 PM
  2. Servlet to Servlet connection through URLConnection
    By bsrjavaforum in forum Networking
    Replies: 0
    Last Post: 04-01-2009, 04:12 PM
  3. Replies: 1
    Last Post: 12-02-2008, 12:23 AM
  4. Replies: 0
    Last Post: 08-30-2008, 11:52 AM
  5. Replies: 1
    Last Post: 08-07-2007, 03:47 PM

Posting Permissions

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