急:我用tomcat配置的servlet环境老是失败!

SlzAgain 2003-04-11 04:08:08
我的tomcat目录在c:\tomcat
我想把自己的工程放在虚拟的目录(e:\jsp)下,
设置了server.xml文件,
<Context path=""
docBase="e:\jsp"
crossContext="true"
debug="0"
reloadable="true"
trusted="false" >
</Context>
然后在e:\jsp下建立了WEB-INF目录,把class文件放在classes目录下
输入:http://locahost:8080/servlet/HelloWorldExample
显示:
HTTP Status 404 - /servlet/HelloWorldExample
type Status report
message /servlet/HelloWorldExample
description The requested resource (/servlet/HelloWorldExample) is not available.

哪个大哥救救我,这个问题弄的我好苦啊!
...全文
43 点赞 收藏 17
写回复
17 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
SlzAgain 2003-04-13
OK
终于调试好了,换了个新的HelloWorld.class
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class HelloWorld extends HttpServlet {


public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");
out.println("<title>Hello World</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World</h1>");
out.println("</body>");
out.println("</html>");
}
}
回复
SlzAgain 2003-04-13
我把上面的那几个连接的地方注释掉了,重新编译了
回复
SlzAgain 2003-04-13
HelloWorldExample:

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorldExample extends HttpServlet {


public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");

String title = rb.getString("helloworld.title");

out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");
out.println("<a href=\"/examples/servlets/helloworld.html\">");
out.println("<img src=\"/examples/images/code.gif\" height=24 " +
"width=24 align=right border=0 alt=\"view code\"></a>");
out.println("<a href=\"/examples/servlets/index.html\">");
out.println("<img src=\"/examples/images/return.gif\" height=24 " +
"width=24 align=right border=0 alt=\"return\"></a>");
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}

修改以后还是出现HTTP Status 500 - 错误

郁闷啊,<servlet-name>invoker</servlet-name> 里面的invoker是固定的?
是不是要在web.xml里面添加HelloWOrldExample的名字?

回复
BloodMaster 2003-04-12
搂主出现"HTTP Status 500 - "错误时的HelloWorldExample
应该是tomcat自带的example吧.我想搂主可以看看代码,它里面调用了一html页面,当你复制HelloWorldExample到test目录下时,该html页面并没带过去,所以造成了"HTTP Status 500 - "错误。
回复
BloodMaster 2003-04-12
reloadable="true"的作用是tomcat会自动检测应用程序的/WEB-INF/lib 和/WEB-INF/classes目录的变化,若reloadable="false"则不会自动检测。
回复
anhuihefei 2003-04-12
请教以下web.xml中
<Context path="/test" debug="0" docBase="E:\jsp" reloadable="true"/>
的reloadable="true"有什么作用?

—————————————————————————————————
梦到故园多少路,酒醒南望隔天涯。
回复
SlzAgain 2003-04-12
谢谢,楼上的各位,我明白tomcat设置虚拟目录了,但是servlet还是有点问题
输入:http://locahost:8080/test/servlet/HelloWorldExample
显示:
HTTP Status 500 -

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

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.util.MissingResourceException: Can't find bundle for base name LocalStrings, locale zh_CN
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:804)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:538)
at HelloWorldExample.doGet(HelloWorldExample.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:466)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
at java.lang.Thread.run(Thread.java:536)



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

Apache Tomcat/4.1.18


错误提示和以前不一样了(我已经在在e:\jsp\WEB-INF下写了web.xml)
回复
SlzAgain 2003-04-12
up
回复
ChinaOne1 2003-04-11
好了,终于学会把根目录放到其他盘上了,好高兴啊,谢谢各位!
回复
BloodMaster 2003-04-11
只需在server.xml中添加
<Context path="/test" debug="0" docBase="E:\jsp" reloadable="true"/>
在e:\jsp\WEB-INF下写一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>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>
</web-app>
然后在WEB-INF目录下建一classes用于放置class文件。
最后输入:http://locahost:8080/test/servlet/HelloWorldExample即可
回复
ChinaOne1 2003-04-11
d:\ 还是 d:/ ??
回复
BloodMaster 2003-04-11
需在e:\jsp\WEB-INF下写一web.xml
回复
pengchy 2003-04-11
在WEB-INF下的web.xml中加上HelloWorldExample的映射就行了.
回复
wilsonGao 2003-04-11
<Context path="/myjsp"
docBase="D:\Proc\myweb\myjsp\test"
crossContext="false"
debug="0"
reloadable="true" >
</Context>
回复
ChinaOne1 2003-04-11
不行啊,我是Tomcat 5.0
回复
pantech_36 2003-04-11
tomcat 根目录西有一个class目录,你把servlet存放在那里,看有没有用
回复
Philzzf 2003-04-11
虚拟目录的设置错了
换成:
<Context path="/test" docBase="e:/jsp"
debug="0" privileged="true"/>

测试servlet的路径换成
http://locahost:8080/test/servlet/HelloWorldExample
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2003-04-11 04:08
社区公告
暂无公告