我第一次接触servlet,完全按书上的做,不知道怎么不能运行,特此请教
TestServlet.java文件package test; 
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 TestServlet extends HttpServlet { 
protected void doGet(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException 

PrintWriter out=response.getWriter(); 
out.println("<html><body><h1>welcome to java world</h1></body></html>"); 
out.flush(); 
}  
}
TestServlet.java文件编译成的TestServlet.class放在C:\tomcat5.5\webapps\ROOT\chap06\WEB-INF\classes\test目录下
还有web.xml文件
<?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>
  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>
<!-- JSPC servlet mappings start -->
<servlet> 
<servlet-name>Test</servlet-name> 
<display-name>Test</display-name> 
<description>A test Servlet</description> 
<servlet-class>test.TestServlet</servlet-class> 
</servlet> <servlet-mapping> 
<servlet-name>Test</servlet-name> 
<url-pattern>/Test</url-pattern> 
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
web.xml文件放在C:\tomcat5.5\webapps\ROOT\chap06\WEB-INF
在浏览器里输入http://localhost:8080/chap06/Test
就是不能运行.请高手帮忙

解决方案 »

  1.   

    在浏览器里输入http://localhost:8080/chap06/servlet/Test试试
      

  2.   

    环境变量CLASSPATH中的加d:\Tomcat 5.0\common\lib\servlet-api.jar
      

  3.   

    HTTP Status 404 - /chap06/Test--------------------------------------------------------------------------------type Status reportmessage /chap06/Testdescription The requested resource (/chap06/Test) is not available.
    --------------------------------------------------------------------------------Apache Tomcat/5.5.20我也写了差不多的小例子,都是这样,真郁闷都搞了n多次拉还是这样。我的配置是tomcat5.5。tomcat下的examples里的例子都可以运行的。我自己的就不可以拉。请大侠帮忙啊
      

  4.   

    楼主你的项目放在C:\tomcat5.5\webapps\ 的名字是甚么?如果是test的话由你的web.xml<servlet-mapping>
    <servlet-name>Test</servlet-name>
    <url-pattern>/Test</url-pattern>
    </servlet-mapping>
    <!-- JSPC servlet mappings end -->
    </web-app>
    输入
    http://localhost:8080/Test
      

  5.   

    我是放在C:\tomcat5.5\webapps\ROOT\