Topic: 请帮助:我的tomcat配置出现了问题不能正常显示servlet

  Print this page

1.请帮助:我的tomcat配置出现了问题不能正常显示servlet Copy to clipboard
Posted by: seanwang
Posted on: 2004-08-16 09:49

目录及文件结构如下:
D:\jakarta-tomcat-4.1.29\conf
server.xml:
<Context path="/DEV" docBase="DEV" debug="0" reloadable="true"/>
D:\jakarta-tomcat-4.1.29\webapps\DEV\ch01\WEB-INF\classes
web.xml:
将原D:\jakarta-tomcat-4.1.29\conf下的xml文件copy到此目录下添加如下内容
<servlet>
<servlet-name>ch01_06</servlet-name>
<servlet-class>ch01_06<servlet-calss>
</servlet>

<servlet-mapping>
<servlet-name>ch01_06</servlet-name>
<url-pattern>/ch01/ch01_06</url-pattern>
</servlet-mapping>
使用此url:http://localhost:8080/DEV/ch01/ch0106 不能访问
我搜了半天,看了手头的几本书还是没有找出解决办法,可能其他初学者也遇到了和我
一样的问题,希望能在这里得到解决

2.Re:请帮助:我的tomcat配置出现了问题不能正常显示servlet [Re: seanwang] Copy to clipboard
Posted by: seanwang
Posted on: 2004-08-16 10:09

要执行得servlet如下:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ch01_06 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>");
out.println("A Web Page");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("Hello there!");
out.println("</BODY>");
out.println("</HTML>");
}
}

出现的错误如下
HTTP Status 404 - /DEV/ch01/ch01_06

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

type Status report

message /DEV/ch01/ch01_06

description The requested resource (/DEV/ch01/ch01_06) is not available.

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

Apache Tomcat/4.1.29

3.Re我的tomcat配置出现了问题不能正常显示servlet [Re: seanwang] Copy to clipboard
Posted by: seanwang
Posted on: 2004-08-16 11:15

我已将D:\jakarta-tomcat-4.1.29\webapps\DEV\ch01\下的
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>My Web Application</display-name>
<description>
A application for test.
</description>
<servlet>
<servlet-name>ch01_06</servlet-name>
<display-name>ch01_06Servlet</display-name>
<description>A test Servlet</description>
<servlet-class>ch01_06</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ch01_06</servlet-name>
<url-pattern>/ch01_06</url-pattern>
</servlet-mapping>
</web-app>
并且修改了server.XML
添加了:<Context path="/sev" docBase="DEV\ch01" debug="0" reloadable="true"/>
http://localhost:8080/sev/ch01_06已经可以运行了。
可为什么不加入上条运行http://localhost:8080/DEV/ch01/ch01_06
就不行呢?

4.Re:请帮助:我的tomcat配置出现了问题不能正常显示servlet [Re: seanwang] Copy to clipboard
Posted by: qupd
Posted on: 2004-08-16 19:13

注意:DEV\ch01\WEB-INF。
你的WEB-INF在ch01目录下,你把DEV作为网站的根目录当然不行了


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923