下面是控制台的结果
2012-7-26 20:35:11 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.6.0\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.6.0\jre\bin;C:/Program Files/Java/jdk1.6.0/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0/bin/../jre/lib/i386;E:\oracle\product\10.2.0\db_1\bin;C:\Program Files\Java\jdk1.6.0\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Thunder Network\KanKan\Codecs;F:\实验 课程设计\新建文件夹\bin;D:\QQPCMgr\6.6.2136.201;E:\sjsas\bin;C:\Program Files\Java\jdk1.6.0\bin;F:\sb\android-sdk-windows\tools;E:\J2EE_Eclipse\eclipse;
2012-7-26 20:35:11 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-7878
2012-7-26 20:35:11 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 634 ms
2012-7-26 20:35:11 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-7-26 20:35:11 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-7-26 20:35:11 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(E:\Tomcat\apache-tomcat-6_win7\webapps\ServletDemo2\WebRoot\WEB-INF\lib\javaee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2012-7-26 20:35:11 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-7-26 20:35:12 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-7-26 20:35:12 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSF
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSP
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Servlet
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo
2012-7-26 20:35:12 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo2
2012-7-26 20:35:12 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-7878
2012-7-26 20:35:12 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2012-7-26 20:35:12 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/32 config=null
2012-7-26 20:35:12 org.apache.catalina.startup.Catalina start
信息: Server startup in 1270 ms
下面是web.xml的文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.servlet.MyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<display-name>第一个servlet</display-name>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/myFirstServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
下面是我的Servlet
package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.HttpRetryException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class MyServlet extends HttpServlet {
public MyServlet(){
super();
}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
PrintWriter out =response.getWriter();
out.print("this is my first servlet");
out.flush();
out.close();
}
}
下面是工程结构 直接建的java project 然后手动在下面添加的WebRoot 跟WEB-INF等文件夹
[img=http://C:\Documents and Settings\Administrator\桌面][/img]
12 个解决方案
#1
404一般2种情况
1.服务器启动出错
2.访问路径出错
LZ应属前种,初步猜测Tomcat缺少必要jar包,因没遇到过,请LZ自行Google
1.服务器启动出错
2.访问路径出错
LZ应属前种,初步猜测Tomcat缺少必要jar包,因没遇到过,请LZ自行Google
#2
初学者常见错误,大小写错误:
<url-pattern>/ myFirstServlet</url-pattern>
而你浏览器的地址是:
http://localhost:7878/ServletDemo2/ MyFirstServlet
必须跟配置文件的大小写完全一致!
<url-pattern>/ myFirstServlet</url-pattern>
而你浏览器的地址是:
http://localhost:7878/ServletDemo2/ MyFirstServlet
必须跟配置文件的大小写完全一致!
#3
+1
#4
你为什么不用myeclipse 啊,eclipse现在基本上蛮少的人用了啊,你可以出错的原因是你的文件中出现了中文,或是你的路径写得有问题
#5
这也是我经常犯的错误 嘿嘿
#6
我以前在学校学的时候都是用myeclipse写的 现在在外面培训 因为对很多东西都不清楚 老师说让我们先用eclpse写 这样人才不会变懒 所以...呵呵
#7
你们老师说的是对的,关键其实不是怕变懒,是怕自动化程度过高而变蠢。
最后离开MyEclipse,连基础的配置和部署都搞不懂了。
先掌握而后化简。
#8
嗯呢
#9
我在环境变量的目录中加了一个tcnative-1.dll文件 那个什么not found倒是没有了
下面是控制台的结果,就是还是404错误 纠结了 在myeclipse下建web工程的话 部署到应用服务器上又能看 但是eclipse下自己手动建就有问题
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: An older version 1.1.20 of the APR based Apache Tomcat Native library is installed, while Tomcat recommends version greater than 1.1.22
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2012-7-27 10:17:52 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:52 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:52 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 971 ms
2012-7-27 10:17:52 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-7-27 10:17:52 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSF
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSP
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Servlet
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo2
2012-7-27 10:17:54 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:54 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:54 org.apache.catalina.startup.Catalina start
信息: Server startup in 1713 ms
下面是控制台的结果,就是还是404错误 纠结了 在myeclipse下建web工程的话 部署到应用服务器上又能看 但是eclipse下自己手动建就有问题
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: An older version 1.1.20 of the APR based Apache Tomcat Native library is installed, while Tomcat recommends version greater than 1.1.22
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2012-7-27 10:17:52 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:52 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:52 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 971 ms
2012-7-27 10:17:52 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-7-27 10:17:52 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSF
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSP
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Servlet
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo2
2012-7-27 10:17:54 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:54 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:54 org.apache.catalina.startup.Catalina start
信息: Server startup in 1713 ms
#10
检查路径
#11
感谢各位亲的 热心帮助 问题已经解决了 把ServletDemo2项目拷到 webapps的时候只要WebRoot文件夹 其余的都删掉
#12
myFirstServlet
大小写问题
大小写问题
#1
404一般2种情况
1.服务器启动出错
2.访问路径出错
LZ应属前种,初步猜测Tomcat缺少必要jar包,因没遇到过,请LZ自行Google
1.服务器启动出错
2.访问路径出错
LZ应属前种,初步猜测Tomcat缺少必要jar包,因没遇到过,请LZ自行Google
#2
初学者常见错误,大小写错误:
<url-pattern>/ myFirstServlet</url-pattern>
而你浏览器的地址是:
http://localhost:7878/ServletDemo2/ MyFirstServlet
必须跟配置文件的大小写完全一致!
<url-pattern>/ myFirstServlet</url-pattern>
而你浏览器的地址是:
http://localhost:7878/ServletDemo2/ MyFirstServlet
必须跟配置文件的大小写完全一致!
#3
+1
#4
你为什么不用myeclipse 啊,eclipse现在基本上蛮少的人用了啊,你可以出错的原因是你的文件中出现了中文,或是你的路径写得有问题
#5
这也是我经常犯的错误 嘿嘿
#6
我以前在学校学的时候都是用myeclipse写的 现在在外面培训 因为对很多东西都不清楚 老师说让我们先用eclpse写 这样人才不会变懒 所以...呵呵
#7
你们老师说的是对的,关键其实不是怕变懒,是怕自动化程度过高而变蠢。
最后离开MyEclipse,连基础的配置和部署都搞不懂了。
先掌握而后化简。
#8
嗯呢
#9
我在环境变量的目录中加了一个tcnative-1.dll文件 那个什么not found倒是没有了
下面是控制台的结果,就是还是404错误 纠结了 在myeclipse下建web工程的话 部署到应用服务器上又能看 但是eclipse下自己手动建就有问题
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: An older version 1.1.20 of the APR based Apache Tomcat Native library is installed, while Tomcat recommends version greater than 1.1.22
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2012-7-27 10:17:52 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:52 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:52 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 971 ms
2012-7-27 10:17:52 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-7-27 10:17:52 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSF
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSP
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Servlet
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo2
2012-7-27 10:17:54 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:54 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:54 org.apache.catalina.startup.Catalina start
信息: Server startup in 1713 ms
下面是控制台的结果,就是还是404错误 纠结了 在myeclipse下建web工程的话 部署到应用服务器上又能看 但是eclipse下自己手动建就有问题
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: An older version 1.1.20 of the APR based Apache Tomcat Native library is installed, while Tomcat recommends version greater than 1.1.22
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.20.
2012-7-27 10:17:52 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2012-7-27 10:17:52 org.apache.coyote.http11.Http11AprProtocol init
信息: Initializing Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:52 org.apache.coyote.ajp.AjpAprProtocol init
信息: Initializing Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:52 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 971 ms
2012-7-27 10:17:52 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2012-7-27 10:17:52 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.35
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor host-manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDescriptor
信息: Deploying configuration descriptor manager.xml
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory docs
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory examples
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSF
2012-7-27 10:17:53 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory PB_JSP
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ROOT
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory Servlet
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo
2012-7-27 10:17:54 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory ServletDemo2
2012-7-27 10:17:54 org.apache.coyote.http11.Http11AprProtocol start
信息: Starting Coyote HTTP/1.1 on http-7878
2012-7-27 10:17:54 org.apache.coyote.ajp.AjpAprProtocol start
信息: Starting Coyote AJP/1.3 on ajp-8009
2012-7-27 10:17:54 org.apache.catalina.startup.Catalina start
信息: Server startup in 1713 ms
#10
检查路径
#11
感谢各位亲的 热心帮助 问题已经解决了 把ServletDemo2项目拷到 webapps的时候只要WebRoot文件夹 其余的都删掉
#12
myFirstServlet
大小写问题
大小写问题