Meu Tomcat não roda servlets

Pessoal, estou apanhando pra fazer o Tomcat rodar servlets :cry:

segue os passos que fiz

em meu server.xml criei um Context para acessar meus arquivos na pasta c:projetos este

... <Context className="org.apache.catalina.core.StandardContext" crossContext="false" reloadable="false" mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="false" debug="0" swallowOutput="false" privileged="false" displayName="Teste" wrapperClass="org.apache.catalina.core.StandardWrapper" docBase="c:projetos este" cookies="true" path="/teste" cachingAllowed="true" charsetMapperClass="org.apache.catalina.util.CharsetMapper"> </Context> ...

Em c:projetos este esta o teste.htm

<html> <body> <p> Teste </p> </body> <html>

Em c:projetos esteWEB-INF esta meu web.xml

[code]<?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>HelloWorld</servlet-class>
</servlet>
</web-app>[/code]

Em c:projetos esteWEB-INFclasses estão os arquivos HelloWorld.java e HelloWorld.class

meu HelloWorld.java :

[code]import java.io.;
import javax.servlet.
;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {

public void doGet&#40;HttpServletRequest request, HttpServletResponse response&#41;
throws IOException, ServletException
&#123;
    response.setContentType&#40;&quot;text/html&quot;&#41;;
    PrintWriter out = response.getWriter&#40;&#41;;
    out.println&#40;&quot;&lt;html&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;body&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;head&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;title&gt;Hello World!&lt;/title&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;/head&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;body&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;h1&gt;Hello World!&lt;/h1&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;/body&gt;&quot;&#41;;
    out.println&#40;&quot;&lt;/html&gt;&quot;&#41;;
&#125;

}[/code]

se chamo: http://localhost:8080/teste/teste.htm, a paginazimha teste.htm é exibida com sucesso,

mas nenhuma das opçoes abaixo funciona

http://localhost:8080/teste/servlet/Hello
http://localhost:8080/teste/servlet/HelloWorld

http://localhost:8080/teste/Hello
http://localhost:8080/teste/HelloWorld

todas dão o erro abaixo:

HTTP Status 404 - /teste/HelloWorld

type Status report
message /teste/HelloWorld
description The requested resource (/teste/HelloWorld) is not available.

Apache Tomcat/4.1.27

Alguem sabe me dizer onde estou “comendo bola” ??? :? :frowning: :cry:

No web.xml vc tem que adicionar para cada servlet a tag servlet mapping:

&lt;web-app&gt; 
  &lt;servlet&gt; 
    &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt; 
    &lt;servlet-class&gt;HelloWorld&lt;/servlet-class&gt; 
  &lt;/servlet&gt; 
  &lt;servlet&gt; 
    &lt;servlet-name&gt;Servlet1&lt;/servlet-name&gt; 
    &lt;servlet-class&gt;Servlet&lt;/servlet-class&gt; 
  &lt;/servlet&gt; 

  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/HelloWorld&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;Servlet1&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/Servlet1&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
&lt;/web-app&gt;

e no servlet name procure sempre colocar o mesmo nome da classe.

acho que com isso vc consegue rodar os servlets.

Valeu, é isso mesmo … :stuck_out_tongue:

é q no livro que estou lendo não fala sobre isso :oops: