tomcat5下配置运行servlet,出现找不到网页错误,在线等!!!!

java_jing 2004-12-20 09:34:26
想在tomcat5下配置运行servlet,在classpath中增加,c:\tomcat5\common\lib\servlet-api.jar;
编译一个Test.java打包并放置在web-inf下的classes目录下的com.cstmail.login目录下,在web-inf下的web.xml中增加
<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>com.cstmail.login.Test</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>

在浏览器中打入:http://localhost/test/test
出现错误:
找不到网页
您要查看的网页可能已被删除、名称已被更改,或者暂时不可用。

--------------------------------------------------------------------------------

请尝试以下操作:

如果您已经在地址栏中输入该网页的地址,请确认其拼写正确。

打开 localhost 主页,然后查找指向您感兴趣信息的链接。
单击后退按钮,尝试其他链接。
单击搜索,寻找 Internet 上的信息。



HTTP 404 - 未找到文件
Internet Explorer

...全文
284 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
szpqq 2004-12-20
  • 打赏
  • 举报
回复
把server.xml中的http端口改成80
java_jing 2004-12-20
  • 打赏
  • 举报
回复

Test.java打包并放置在c:/tomcat/webapps/test/web-inf下的classes目录下的com.cstmail.login目录下了,你是说应改成
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test/test</url-pattern>
</servlet-mapping>

我重启后:http://localhot/test/test还是不行啊,找不到网页.!!!1!1!!
pengpong 2004-12-20
  • 打赏
  • 举报
回复
up
zjgj 2004-12-20
  • 打赏
  • 举报
回复
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>这里应该写站点根目录下的</url-pattern>
</servlet-mapping>
java_jing 2004-12-20
  • 打赏
  • 举报
回复
我的是用win2000的,在apache的httpd.conf中已经加入了.
LoadModule jk_module modules/mod_jk.dll

JkWorkersFile "c:/tomcat5/conf/workers.properties"
JkMount /servlet/* ajp13
JkMount /*.jsp ajp13

且现在整合后运行jsp正常,但servlet不行啊,
tom2005 2004-12-20
  • 打赏
  • 举报
回复
看看这个是否有帮助

http://www.neweasier.com/article/2003-04-06/1049609629.html
java_jing 2004-12-20
  • 打赏
  • 举报
回复
谁知道怎样整合apache1.3+tomcat5,使运行servlet时不用打8080端口号,谢谢,google中搜了一下,没太看到啊,
java_jing 2004-12-20
  • 打赏
  • 举报
回复
我用的tomcat5和apache整合的,所以觉得不用填,但加上端口号后,的确是好用了,应该是两者整合时,http.conf还需要进行配置吧,谢谢了,
tom2005 2004-12-20
  • 打赏
  • 举报
回复
http://localhost:8080/test/test

web-inf要大写
speedingman 2004-12-20
  • 打赏
  • 举报
回复
tomcat的断口是8080,填了嘛?
java_jing 2004-12-20
  • 打赏
  • 举报
回复
补充一下,还照着一篇文章所言,打开../Tomcat5/conf/web.xml
找到下面一段注释:
<!-- The "invoker" servlet, which executes anonymous servlet classes -->
<!-- that have not been defined in a web.xml file. Traditionally, this -->
<!-- servlet is mapped to the URL pattern "/servlet/*", but you can map -->
<!-- it to other patterns as well. The extra path info portion of such a -->
<!-- request must be the fully qualified class name of a Java class that -->
<!-- implements Servlet (or extends HttpServlet), or the servlet name -->
<!-- of an existing servlet definition. This servlet supports the -->
<!-- following initialization parameters (default values are in square -->
<!-- brackets): -->
<!-- -->
<!-- debug Debugging detail level for messages logged -->
<!-- by this servlet. [0] -->
将下面的注释去掉,
<!--
<servlet>
<servlet-name>invoker</servlet-name>
<servlet-class>
org.apache.catalina.servlets.InvokerServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
-->
然后再找到:
<!-- The mapping for the invoker servlet -->
将下面注释去掉就可以了。
<!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
-->


在浏览器中http://localhost/servlet/HelloWorld能显示页面!!
当时http://localhost/test/test也能显示页面,但重新启动后,两个就都不好使了,出现同样的错误,是

IE报的错误,HTTP 404 - 未找到文件
Internet Explorer


十分奇怪,也十分郁闷,望高手指点,我实在是没着了先谢谢了

java_jing 2004-12-20
  • 打赏
  • 举报
回复
终于知道答案了,应该是在httpd.conf加入些段,
Alias /test/ "c:/tomcat5/webapps/test/"
<Directory "c:/tomcat5/webapps/test/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
使之认识tomcat的这个应用.
yu7058560 2004-12-20
  • 打赏
  • 举报
回复
应该是个部署的问题。
java_jing 2004-12-20
  • 打赏
  • 举报
回复
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, guojing@cstnet.cn and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.



--------------------------------------------------------------------------------

Apache/1.3.22 Server at 159.226.58.14 Port 80

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧