书上是这样说的:
    例如建立new这个项目,在webapps下建立new文件夹,然后在这个文件夹下建立new.xml,然后编辑这个文档如下:
<contextpath="/new"docBase="c:\new"debug="0"privileged="true"></Context>
    然后在Tomcat\webapps\new下创建index.txt文件,文件内容如下:
<%@ page language="java" %>
<html>
<head>
<title>Hello World!</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<% out.println("Hello World!"); %>
</body>
</html>
然后把它的文件名改为index.jsp,在浏览器地址栏中输入http://localhost:8080/new,就可以浏览到。可是我这样做却是这样的结果:
HTTP Status 404 - /new--------------------------------------------------------------------------------type Status reportmessage /newdescription The requested resource (/new) is not available.
--------------------------------------------------------------------------------Apache Tomcat/5.0.28

解决方案 »

  1.   

    new.xml要放到tomcat的conf\Catalina\localhost下,同时new文件夹下应该有个WEB-INF文件夹,里面放web.xml文件,可以看看\webapps\ROOT文件夹的结构和内容
      

  2.   

    谢谢楼上的两位啊!
    那WEB-INF里除了web.xml文件,还需要别的吗?(像我这个简单的例子)
    web.xml文件里要写些什么呢?
    我看了\webapps\ROOT文件夹的结构和内容
    刚刚学习,不懂里面的内容!
    我现在只是想试试这个简单的例子,显示出东西来,目的就达到了。
      

  3.   

    可以放2个空文件夹:lib和class,lib是放程序可能用到的jar文件,class是放自己编写的java类文件的
      

  4.   

    web.xml文件里要写些什么呢?
    root里的那个直接拷过来也不行吧
      

  5.   

    直接用  \Tomcat 5.0\webapps\servlets-examples\WEB-INF\web.xml里面的 东西,改一点点就可以了
      

  6.   

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee      
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
      version="2.4">
      
    <display-name>123</display-name>
      <description>
         123
      </description>
    </web-app>
      

  7.   

    我试了,不行啊
    出现如下页面:
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: Wrapper cannot find servlet class org.apache.jsp.index_jsp or a class it depends on
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    java.lang.Thread.run(Unknown Source)
    root cause java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    java.lang.Thread.run(Unknown Source)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.
    --------------------------------------------------------------------------------Apache Tomcat/5.0.28
      

  8.   

    craig_wolfdon() 前辈:
    我用你给的web.xml,出现如下页面:
    Directory Listing For /--------------------------------------------------------------------------------
    Filename Size Last Modified 
       index.jsp.txt 0.1 kb Thu, 05 Apr 2007 07:11:04 GMT --------------------------------------------------------------------------------Apache Tomcat/5.0.28
      

  9.   

    其实也不必须,你看看jsp-examples里面的结构就知道了,
      

  10.   

    谢谢你啊,也没什么工程啊,就是要这个小例子new,在页面上显示“Hello World!”这样一行字而已。唉,怎么出不来啊
      

  11.   

    Filename Size Last Modified 
       index.jsp.txt 0.1 kb Thu, 05 Apr 2007 07:11:04 GMT 
    =====================================================
    看你的index.jsp文件扩展名是.jsp吗 ?  
    你的怎么是:index.jsp.txt  啊?
    我也是新手。呵呵~~