tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Paul <antonypau...@gmail.com>
Subject Re: Deploying a Servlet to Tomcat 5.0
Date Tue, 25 Jan 2005 06:41:39 GMT
You have to add a mapping for the servlet in the WEB-INF/web.xml file.
Look at the examples directory in webapps for sample.

rgds
Antony Paul


On Mon, 24 Jan 2005 22:04:17 -0800 (PST), Harsha perera
<harsha_l_perera@yahoo.com> wrote:
> Hi,
> 
> I have been trying to deploy a simple servlet to
> Tomcat 5.0. Tomcat is installed on WIndows XP.
> 
> This is what I did:
> 1. Created a directory structure under
>    $TOMCAT_HOME\webapps as follows:
>    ROOT\WEB-INF\classes
> 
> 2. Moved the class(HelloServlet.class) to the
>    above created directory.
> 
> 3. Bounced Tomcat.
> 
> 4. Attempting to access the class as
>    http://localhost:8080/servlet/HelloServlet gives
>    me the error:
>    HTTP Status 404 - /servlet/HelloServlet
> 
> --------------------------------------------------------------------------------
> 
> type Status report
> 
> message /servlet/HelloServlet
> 
> description The requested resource
> (/servlet/HelloServlet) is not available.
> 
> Please advise on how I should be deploying this simple
> servlet.
> 
> The servlet is code is given below:
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
> 
> /** Simple servlet used to test server.
>  *  <P>
>  *  Taken from Core Servlets and JavaServer Pages 2nd
> Edition
>  *  from Prentice Hall and Sun Microsystems Press,
>  *  http://www.coreservlets.com/.
>  *  © 2003 Marty Hall; may be freely used or
> adapted.
>  */
> 
> public class HelloServlet extends HttpServlet {
>   public void doGet(HttpServletRequest request,
>                     HttpServletResponse response)
>       throws ServletException, IOException {
>     response.setContentType("text/html");
>     PrintWriter out = response.getWriter();
>     String docType =
>       "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
> +
>       "Transitional//EN\">\n";
>     out.println(docType +
>                 "<HTML>\n" +
>                 "<HEAD><TITLE>Hello</TITLE></HEAD>\n"
> +
>                 "<BODY BGCOLOR=\"#FDF5E6\">\n" +
>                 "<H1>Hello</H1>\n" +
>                 "</BODY></HTML>");
>   }
> }
> 
> Regards
> Harsha
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message