如何使用tomcat的manager功能?

如何使用tomcat的manager功能?

使用tomcat4的manager功能的试验与体会。

一)启用manager功能。
在测试Struts的时候,修改了struts-config.xml文件,需要重启tomcat进行测试。
每次重启感觉很麻烦,突然想起以前使用过的tomcat的manager功能,可以很方便的对web application进行启动、停止、重启、移除等操作,可省却频繁重新启动整个容器服务器的麻烦。

可输入地址:http://localhost:8080/manager/html总提示没有权限。
打开server/webapps/manager目录,没有看到jsp、Servlet文件。是不是没有找到相应的管理Servlet.它应该web.xml文件定义映射。
系统使用了:org.apache.catalina.servlets.HTMLManagerServlet,这个类在j2ee.jar包中。
将j2ee.jar放server/webapps/manager/WEB-INF/lib下,重新启动tomcat.
发现提示信息:由于j2ee.jar包中包括了Servlet.class,违反了Servelet2.3的规范,tomcat没有装载该jar.
用winrar打开该文件,删除Servlet目录。
重新启动tomcat,还是不能使用manage功能。

没有办法,硬着头皮看它的E文帮助文档。原来需要在conf/tomcat-users.xml文件中加入管理的角色。
在xml文件中添加一行, <role rolename="manager"/>
并给root授权。<user username="root" password="root" roles="tomcat,role1,admin,manager"/>

重新启动,一切OK。可以使用tomcat的管理功能了,很方便的。大家可以试一试。

二)manage使用体会。
其实这个体会是我以前在使用的时候,随手做的笔记。
大家有兴趣,可以先读一读,有问题再与我联系。

version:4.1.24
by caozhaoyong

1. tomcat directories structure of webapps.
you have many ways to define context(root virtual path and file path, it's a map.):
a. define context in file: tomcat/conf/server.xml, the content likes this:
<Context path="/a" docBase="e:/a" debug="0" privileged="true" reloadable="true">
</Context>
b. put the content block in a seperate file xxx.xml,and copy the file to tomcat/webapps/. Rember: one file maps one web application, you can specifile the xml file name as you want.
c. put your web application directory in tomcat/webapps, and then you can visit it: .../yourwebapp.
you need tomcat first.
Tomcat will check $tomcat$/webapps/*.xml files, add all these contexts and all directories in tomcat/webapps
to the tomcat services, don't try to put some other formatted xml files here, tomcat will complain some errors at
the start stage.
you can visit all the directories in tomcat/webapp/, http://localhost:8080/webapplicationname

2. Root is a special directory, you can't visit it via http://localhost:8080/Root.
You can renane Root to root and then you can treat it as regular directory and normal web application.
You can change the default root webapp in tomcat/conf/server.xml file,check it.

3. use "Tomcat Web Application Manager " to manager web application.
the manager url is : http://localhost:8080/manager/html/
you can start, stop, reload and remove the web applicaitons.
manager lists all the web applications in tomcat services.
if you add some new web applications, you should restart tomcat and then the manager can list the new
web application name, then you can operate the web application.
but you have another way to achieve it, use install method in manager.
input your new context: /aaa
input the real directory: file://D:/Tomcat/webapps/aaa
click: install
you can visit your new web application: http://localhsot:8080/aaa

Caution:
1. if you don't define web-inf in aaa, you can use the web application just after you install it.
but if you restart tomcat, the webapp will be unvaliable.
You must create web-inf in you web applicaiton, but you can let the directory include nothing.
2. don't use "remove" in manager pages if your web application directory just in tomcat/webapps,
it will drop your webpplicaiton from you hard disk completely!
If your web application in other directories, you can just remove the context from tomcat services.
and you can reinstall it to the services or restart tomcat.

End..

hajavaor@eyou.com

19843788