tomcat中路径的问题

whp320 2006-03-19 12:48:58
我安装好Tomcat以后,设置了环境变量TOMCAT_HOME C:\Program Files\Apache Software Foundation\Tomcat 5.0 将我的Web站点发布到Webapps目录下,启动Tomcat服务.在IE中输入
http://localhost:8080/myweb.不会弹出我的主页(index.jsp).但是,当我把myweb文件夹放到jsp-examples这个目录下的时候。在IE中输入http://localhost:8080/jsp-examples/myweb。我的主页就出来了。请问:这是为什么?是不是我还有什么东西没有设置?
错误信息如下:
HTTP Status 500 -

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

type Exception report

message

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

exception

org.apache.jasper.JasperException: Unable to compile class for JSP


...全文
320 点赞 收藏 14
写回复
14 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
whp320 2006-03-20
多谢各位朋友,已经说的很清楚了,尤其感谢: qingyuan18(zealot_tang) xian0701(青苔) tanyun1111(TY)的帮助
回复
web.xml注意大小写
回复
qingyuan18 2006-03-20
tomcat的webApps目录应该是放编译后的class文件,它有自己的一套项目目录结构。

其实只要你是web项目,应该包括jsp, web-inf,work三个文件夹,其中jsp放*.jsp源文件,work中包括*.jsp编译后的serlet和*.class文件,web-inf中再分classes,src,lib文件夹(src如果不想打包可以放到外头), classes目录放编译后的class文件,lib放项目运行需要的jar包

按照这个结构,只需要在tomcat的server.xml中配一条:
<Context path="" reloadable="true"
docBase="放你的项目包的路径" workDir="项目包下work的路径"/>
就可以了!



回复
xian0701 2006-03-20
Add a <Context> entry in the Tomcat server.xml configuration file. This approach is
described briefly below, and allows you to position the document root of your web
application at some point other than the $TOMCAT_HOME/webapps/ directory. Doing this requires the following steps:

1.Open file $TOMCAT_HOME/conf/server.xml in an editor.
2.Navigate to the bottom of the file.
3.Add a new <Context> element for your application, using the existing examples as a guide:

The following attributes are supported:
path. The context path for your application, which is the prefix of a request URI that tells Tomcat which application should be used to process this request. For example, if you set your path to "/catalog", any request URI beginning with "/catalog" will be processed by this application. This attribute is requrired, and must start with a slash ('/') character.

docBase. The document root directory for this web application. This can be a relative path(relative to the directory in which Tomcat is started), or an absolute path, to the directory containing your app. On a Windows platform, you MUST use the drive prefix and a colon when specifying an absolute path. This attribute is required.

debug. Debugging detail level (from "0" to "9") that defines how verbose Tomcat's logging messages will be when your application is initialized, started, and shut down. The default value is "0" (minimal logging) if you do not specify a different value.

reloadable. Set to "true" if you want Tomcat to watch for changes to Java class files in the WEB-INF/classes directory, or JAR files in the WEB-INF/lib directory. If such a change is noted, Tomcat will shut down and reload your application automatically, picking up these changes. The default value ("false") means that such changes will be ignored. NOTE: While this feature is very useful during development, it requires overhead to do the checking. This capability should generally not be used in deployed production applications.
回复
xian0701 2006-03-20
whp320(征服者) :

你的<Context path="abc" docBase="H:\work\abc\abc" debug="5"
reloadable="true" crossContext="true" privileged="true">path="abc"写成path="/abc"试试
回复
feixianking 2006-03-19
是web.xml
回复
feixianking 2006-03-19
在XML里面配置一下welcome file 为index.jsp才行
回复
whp320 2006-03-19
另外,我如何在JBuilder中加入我的tomcat5.0
回复
whp320 2006-03-19
zbg2cd99(东北刚子)我按照你说的方法加了<Context path="abc" docBase="H:\work\abc\abc" debug="5"
reloadable="true" crossContext="true" privileged="true">
在IE里面输入:http://localhost:8080/abc但是还是不可以。请问。。。。我还有什么地方没有设置正确?
回复
zjr1983 2006-03-19
各位行家好,我也是初学者,我安装tomcat后,设好了环境变量,在地址栏里输入了http://localhost:8080后为什么进入不了tomcat的首页啊?苦恼好久了请各位指教!谢谢
回复
zbg2cd99 2006-03-19
你没有必要一定要放在WEBAPPS中,你可以放到其他路径,但是必须要在conf\Catalina\localhost路径下 建立一个***.xml的文件,里面的内容是
<Context path="/web" docBase="D:\web"
debug="5" reloadable="true" crossContext="true">

</Context>
"D:\web"为在地址栏里输入的名字,例如http://localhost:8080/web
"/web"为WEBAPPS中的文件名.
回复
tanyun1111 2006-03-19
我觉得没必要把站点放在webapps目录下,随便放哪都行,只要写个简单的配置文件指向那个路径就行了,给个例子给你看看:
找到你的...\Tomcat 5.0\conf\Catalina\localhost目录,在里面建一个.xml的文件,文件名可随便,然后在这个xml文件里写入如下内容后保存就可以了
<Context path="" docBase="D:\myweb" debug="0" privileged="true" reloadable="true"/>
假如你的web在D盘,那么docBase就得指向那个路径就可以了
回复
whp320 2006-03-19
可为什么我放到 C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\jsp-examples这个路径下就可以了呢?
回复
whp320 2006-03-19
上面两位朋友说的什么意思啊?我在 C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps目录下放了我的站点,名字假如叫做MyWeb.里面有个目录叫做WEB-INF.这个目录下面有feixianking(竹影仙踪)说的Web.xml文件,我打开后需要配置什么吗?
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-03-19 12:48
社区公告
暂无公告