tomcat7 远程调试摘要认证 随机数

扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
Tomcat7中文文档(配置说明详解).doc
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer-4.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口当前位置:&&
本页文章导读:
&&&&?redis的安装&&&&&&一、下载redis
/p/servicestack/wiki/RedisWindowsDownload#Download_32bit_Cygwin_builds_for_Windows
把redis-2.02.zip解压到d盘,在解压后的文件中增加redis.conf文件,内容如下
# Redis configurati......&&&&?详解HTTP中的摘要认证机制&&&&&&&&&&&&& 在上一期http://blog.csdn.net/tenfyguo/article/details/6167190中笔者较为详细的介绍了HTTPBasic认证在apache下的配置,通过简单的实验演示了HTTP Basic认证的基本原理。
&nbsp......&&&&?关于Block代码块的使用方法&&&&&&
二、构成了解
&NSString* (^blocks)(NSString*)= ^(NSString *str)
& & & & //NSLog(@&this is :%@&,str);
后面括号跟的是......
&&&&&&最新IT科技资讯推荐:
[1]redis的安装
&&&&来源:&互联网& 发布时间:&
一、下载redis
/p/servicestack/wiki/RedisWindowsDownload#Download_32bit_Cygwin_builds_for_Windows
把redis-2.02.zip解压到d盘,在解压后的文件中增加redis.conf文件,内容如下
# Redis configuration file example
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize no
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
# You can specify a custom pid file location here.
pidfile /var/run/redis.pid
# Accept connections on the specified port, default is 6379
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for connections.
# bind 127.0.0.1
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 300
# Set server verbosity to 'debug'
# it can be one of:
# debug (a lot of information, useful for development/testing)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel debug
# Specify the log file name. Also 'stdout' can be used to force
# the demon to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile stdout
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT &dbid& where
# dbid is a number between 0 and 'databases'-1
databases 16
################################ SNAPSHOTTING
#################################
# Save the DB on disk:
save &seconds& &changes&
Will save the DB if both the given number of seconds and the given
number of write operations against the DB occurred.
In the example below the behaviour will be to save:
after 900 sec (15 min) if at least 1 key changed
after 300 sec (5 min) if at least 10 keys changed
after 60 sec if at least 10000 keys changed
save 900 1
save 300 10
save 60 10000
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
# The filename where to dump the DB
dbfilename dump.rdb
# For default save/load DB in/from the working directory
# Note that you must specify a directory not a file name.
################################# REPLICATION #################################
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
# slaveof &masterip& &masterport&
# If the master is password protected (using the &requirepass& configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
# masterauth &master-password&
################################## SECURITY ###################################
# Require clients to issue AUTH &PASSWORD& before processing any other
# commands.
This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
# requirepass foobared
################################### LIMITS ####################################
# Set the max number of connected clients at the same time. By default there
# is no limit, and it's up to the number of file descriptors the Redis process
# is able to open. The special value '0' means no limts.
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
# maxclients 128
# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys with an
# EXPIRE set. It will try to start freeing keys that are going to expire
# in little time and preserve keys with a longer time to live.
# Redis will also try to remove objects from free lists if possible.
# If all this fails, Redis will start to reply with errors to commands
# that will use more memory, like SET, LPUSH, and so on, and will continue
# to reply to most read-only commands like GET.
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
# 'state' server or cache, not as a real DB. When Redis is used as a real
# database the memory usage will grow over the weeks, it will be obvious if
# it is going to use too much memory in the long run, and you'll have the time
# to upgrade. With maxmemory after the limit is reached you'll start to get
# errors for write operations, and this may even lead to DB inconsistency.
# maxmemory &bytes&
############################## APPEND ONLY MODE ###############################
# By default Redis asynchronously dumps the dataset on disk. If you can live
# with the idea that the latest records will be lost if something like a crash
# happens this is the preferred way to run Redis. If instead you care a lot
# about your data and don't want to that a single record can get lost you should
# enable the append only mode: when this mode is enabled Redis will append
# every write operation received in the file appendonly.log. This file will
# be read on startup in order to rebuild the full dataset in memory.
# Note that you can have both the async dumps and the append only file if you
# like (you have to comment the &save& statements above to disable the dumps).
# Still if append only mode is enabled Redis will load the data from the
# log file at startup ignoring the dump.rdb file.
# The name of the append only file is &appendonly.log&
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# log file in background when it gets too big.
appendonly no
# The fsync() call tells the Operating System to actually write data on disk
# instead to wait for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
# Redis supports three different modes:
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log . Slow, Safest.
# everysec: fsync only if one second passed since the last fsync. Compromise.
# The default is &always& that's the safer of the options. It's up to you to
# understand if you can relax this to &everysec& that will fsync every second
# or to &no& that will let the operating system flush the output buffer when
# it want, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting).
appendfsync always
# appendfsync everysec
# appendfsync no
############################### ADVANCED CONFIG ###############################
# Glue small output buffers together in order to send small replies in a
# single TCP packet. Uses a bit more CPU but most of the times it is a win
# in terms of number of queries per second. Use 'yes' if unsure.
glueoutputbuf yes
# Use object sharing. Can save a lot of memory if you have many common
# string in your dataset, but performs lookups against the shared objects
# pool so it uses more CPU and can be a bit slower. Usually it's a good
# When object sharing is enabled (shareobjects yes) you can use
# shareobjectspoolsize to control the size of the pool used in order to try
# object sharing. A bigger pool size will lead to better sharing capabilities.
# In general you want this value to be at least the double of the number of
# very common strings you have in your dataset.
# WARNING: object sharing is experimental, don't enable this feature
# in production before of Redis 1.0-stable. Still please try this feature in
# your development environment so that we can test it better.
# shareobjects no
# shareobjectspoolsize 1024
启动redis:
输入命令:redis-server.exe redis.conf
启动cmd窗口要一直开着,关闭后则Redis服务关闭。
这时服务开启着,另外开一个窗口进行,设置客户端:
输入命令:redis-cli.exe
输入后如下图所示
然后就可以开始玩了
作者:kai_wei_zhang 发表于 12:41:04 原文链接
阅读:78 评论:0 查看评论
[2]详解HTTP中的摘要认证机制
&&&&来源:&互联网& 发布时间:&
&&&&&&& 在上一期http://blog.csdn.net/tenfyguo/article/details/6167190中笔者较为详细的介绍了HTTPBasic认证在apache下的配置,通过简单的实验演示了HTTP Basic认证的基本原理。
&&&&&& 但是,聪明的读者很快可以发现,这种认证方式是存在很多缺陷的,具体表现如下:
1,& Basic认证会通过网络发送用户名和密码,并且是以base64的方式对用户名和密码进行简单的编码后发送的,而base64编码本身非常容易被解码,所以经过base64编码的密码实际上是明文发送的。
2,& 即使密码是经过加密传输的,当第三方用户仍然可以捕获被修改过的用户名和密码,并将修改过的用户名和密码反复多次的重放给原始服务器,以获得对服务器的访问权,Basic认证没有什么措施可以用来防止这些重放攻击。
3,& 一些不良习惯会使得Basic认证更加危险,那就是用户由于受不了大量密码保护的服务,会在这些不同的服务间使用相同的用户名和密码。
4,& Basic认证没有提供任何针对代理和作为中间人的中间节点的防护措施,它们没有修改认证首部,但却能够修改报文的其余部分,这样就严重的改变了事务的本质。即Basic认证没法支持对内容或者报文本身的保护。
5,& Basic不支持对称认证,即客户端无法认证服务器的合法性,因此客户端很容易被钓鱼到一个非法的服务器从而输入了用户名和密码。
&&&&& 综上,Basic 认证存在很多的不足,使得一般只能用在一些非常简单场景而不能很好的支持真正的产品级别的运用。
&&&& 下面要介绍的另外一种认证,摘要认证则针对Basic认证存在的诸多问题而进行的改良方案。
&&&&& 摘要认证时另外一种HTTP认证协议,它试图修复Basci认证的严重缺陷,即进行如下改进:
1,& 通过传递用户名,密码等计算出来的摘要来解决明文方式在网络上发送密码的问题。
2,& 通过服务产生随机数nonce的方式可以防止恶意用户捕获并重放认证的握手过程。
3,& 通过客户端产生随机数cnonce的方式,支持客户端对服务器的认证。
4,& 通过对内容也加入摘要计算的方式,可以有选择的防止对报文内容的篡改。
& & & & 但是,摘要认证并不是罪安全的协议,也无法满足安全HTTP事务的很多需求,对这些需求来说,可能使用HTTPS方式更为合适。
一,用摘要保护密码
&&&& & 摘要认证的一个改进之处是用摘要代替密码的传输,遵循的基本原则是“绝对不通过网络发送明文密码”,而是发送一个密码的摘要信息,并且这摘要信息是不可逆的,即无法通& 过摘要信息反推出密码信息。而服务器本身是存储这个密码的(实际上,服务器只需知道密码的摘要即可),而客户端和服务器本身都知道这个密码。这样的话,服务器可以读取客户端的摘要和本身知道的密码进行同样计算得出的摘要进行比较,若匹配,则验证通过。
& & && 摘要是对信息主体的浓缩,摘要是一种单向函数,主要用于将无限的输入值转为有限的浓缩输出值,如MD5,则是将任意长度的字节系列转换为一个128位的摘要。MD5输出的128位的摘要通常会写出32个十六进制的字符,每个字符表示4个bit。
二,用随机数防止重放攻击
&&&&&&& 使用单向摘要就无需以明文形式发送密码了,可以只发送密码的摘要,并且可以确信,没有哪个恶意用户能轻易的从摘要中解码出原始密码。
&&&&&&& 但是,摘要被截获也可能跟密码一起好用,为了防止重放攻击的发送,服务器可以向客户端发送一个称为随机数nonce的特殊令牌,这个数会经常发生变化(可能是每毫秒,或者每次认证都发生变化,具体由服务器控制),客户端在计算摘要之前要先将这个随机数附加到密码上去。这样,在密码中加入随机数就会使得摘要随着随机数的每次变化而变化,记录下的密码摘要只对特定的随机数有效,而没有密码的话,攻击者就无法计算出正确的摘要,这样就可以防止重放攻击的发生。
& & & & 摘要认证要求使用随机数,随机数是在WWW-Authenticate服务器质询响应中从服务器传输给客户端的。
三,摘要认证的握手过程
1,& 第一次客户端请求的时候,服务器产生一个随机数nonce,服务器将这个随机数放在WWW-Authenticate响应头,与服务器支持的认证算法列表,认证的域realm一起发送给客户端,如下例子:
HTTP /1.1 401 Unauthorized
WWW-Authenticate:Digest
realm= ”test realm”
qop=auth,auth-int”
nonce=”66C4EF58DA7CB956BD04233FBB64E0A4”
2,& 客户端发现是401响应,表示需要进行认证,则弹出让用户输入用户名和密码的认证窗口,客户端选择一个算法,计算出密码和其他数据的摘要,将摘要放到Authorization的请求头中发送给服务器,如果客户端要对服务器也进行认证,这个时候,可以发送客户端随机数cnonce。如下例子:
GET/cgi-bin/checkout?a=b HTTP/1.1
Authorization: Digest
username=”tenfyguo”
&&&&&&&&&&realm=”test realm”
&&&&&&&&&&nonce=” 66C4EF58DA7CB956BD04233FBB64E0A4” //服务器端的随机数一起带回
&&&&&&&&&&uri=”/cgi-bin/checkout?a=b” //必须跟请求行一致
&&&&&&&&& qop=”auth” //保护质量参数
&&&&&&&&& nc=0000001
&&&&&&&&& cnonce=”xxxxxstrwerr65sgdrftdfytryts” //客户端随机数,用于对称校验
&&&&&&&&& response=” ABC4EF58DA7CB956BD04345FBB64E0A4”//最终摘要
3,& 服务接受摘要,选择算法以及掌握的数据,重新计算新的摘要跟客户端传输的摘要进行比较,验证是否匹配,若客户端反过来用客户端随机数对服务器进行质询,就会创建客户端摘要,服务可以预先将下一个随机数计算出来,提前传递给客户端,通过Authentication-Info发送下一个随机数。如下例子:
HTTP/1.1 200 OK
Authorization-Info:nextnonce=” 88C4EF58DA7CB956BD04233FBB64E0A4”
qop=”auth”
rspauth=”DfasetwerwgDTerGDTERERRE”
cnonce=” xxxxxstrwerr65sgdrftdfytryts”
四,摘要的计算
在说明如何计算摘要之前,先说明参加摘要计算的信息块。信息块主要有两种:
1,表示与安全相关的数据的A1。
A1中的数据时密码和受保护信息的产物,它包括用户名,密码,保护域和随机数等内容,A1只涉及安全信息,与底层报文自身无关。
若算法是:MD5
则A1=&user&:&realm&:&password&
若算法是:MD5-sess
则A1=MD5(&user&:&realm&:&password&):&nonce&:&cnonce&
2,表示与报文相关的数据的A2.
A2表示是与报文自身相关的信息,比如URL,请求反复和报文实体的主体部分,A2加入摘要计算主要目的是有助于防止反复,资源或者报文被篡改。
若qop未定义或者auth:
A2=&request-method&:&uri-directive-value&
若qop为auth:-int
A2=&request-method&:&uri-directive-value&:MD5(&request-entity-body&)
下面定义摘要的计算规则:
若qop没有定义:
摘要response=MD5(MD5(A1):&nonce&:MD5(A2))
若qop为auth:
摘要response=MD5(MD5(A1):&nonce&:&nc&:&cnonce&:&qop&:MD5(A2))
若qop为auth-int:
摘要response= MD5(MD5(A1):&nonce&:&nc&:&cnonce&:&qop&:MD5(A2))
五,随机数的生成
RFC2617建议采用这个假想的随机数公式:
&nonce = BASE64(time-stamp MD5(time-stamp &“:”&ETag& “:”& private-key))
time-stamp是服务器产生的时间戳或者其他不会重复的序列号,ETag是与所请求实体有关的HTTP ETag首部的值,priviate-key是只有服务器知道的数据。
这样,服务器就可以收到客户端的认证首部之后重新计算散列部分,如果结果与那个首部的随机数不符,或者是时间戳的值不够新,就可以拒绝请求,服务器可以通过这种方式来限制随机数的有效持续时间。
包括了ETag可以防止对已经更新资源版本的重放请求。注意:在随机数中包含客户端IP,
[3]关于Block代码块的使用方法
&&&&来源:&互联网& 发布时间:&
首先需要了解的是Block是一个代码块,是一个变量的形式存在的。
二、构成了解
我们需要在函数中声明block,因为是变量的形式,而且存在静态变量形式
&NSString* (^blocks)(NSString*)= ^(NSString *str)
& & & & //NSLog(@&this is :%@&,str);
返回值类型是字符串,如同函数一样,返回值类型写在最前面
^blocks是声明一个代码块,名字叫做blocks
后面括号跟的是参数的类型,如果没有参数返回void,如果有多个参数类型,那么逗号分隔列出
等于号后面的是参数名列表。
因为写的是一个有返回值的block,所以需要return一个与返回值类型相同类型的值,这里返回的是参数字符串
int (^david)(int)= ^(int num)
& & & & return num*5;
这里的返回值类型是一个int,代码块名字叫做david,参数是一个int类型的变量
等于号后面是参数列表,执行的语句是return num *5这句话。
因为如上的两个例子都是有返回值的类型,那么我在调用的时候可以直接使用。
& & NSLog(@&this is block:%@&,blocks(@&hello&));
& & NSLog(@&this is block:%d&,blocks(5));
void (^david)(void)= ^(void)
& & & & & & NSLog(@&I am a block code!&);
这里只是简单的执行了一句话,调用方法就是直接打印或者当作变量直接使用。
作者:yangbo_hbzjk 发表于 11:16:09 原文链接
阅读:0 评论:0 查看评论
最新技术文章:
特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!
(C)2012-,站长邮箱:www_169it_(请将#改为@)(重庆电子工程职业学院,重庆& 401331)
摘要:Web应用程序可以通过在Web服务器启动之前进行部署,这种静态部署的方式并不灵活,部署和卸载都需要对服务器进行操作,而动态部署则可以在服务器运行的状态下部署Web应用程序。Tomcat7通过自带的Web应用程序manager,全面支持动态部署,并且能够对服务器中Web应用程序进行管理。
关键词:Web服务器;静态部署;动态部署;Web应用程序
中图分类号:[G714]&&&&&&&&&&&&&&&&&&&&&&& 文献标识码:A&&&&&&&&&&&&&&&&&&& 文章编号:(0-01
&&&&&&& 一、引言
&&&&&&& 动态部署,名如其意,就是在Web服务器运行时部署依赖它的Web应用程序。对于所欲的Web服务器来说,动态部署是一个非常有必要实现的功能,除了能部署新的Web应用程序之外,还能够对存在的项目取消部署,而这些都是在服务器仍处于运行状态的情形下实现的。本文以Apache Tomcat服务器为例,对其动态部署的方式进行研究。
&&&&&&& 二、Tomcat7简介
&&&&&&& Tomcat是由Apache软件基金会下属的Jakarta项目开发的一个Servlet容器,依照原Sun Microsystems提供的技术规范,实现了对Servlet和JavaServer Page(JSP)的支持,并提供了作为Web服务器的一些特有功能[1]。由于Tomcat本身也内含了一个HTTP服务器,它也可以被视作一个单独的Web服务器。因为同属于Apache软件基金会的下属项目,经常会有程序员混淆Apache Web Server和Tomcat,认为它们就是一个服务器;其实不然,Apache Web Server 是一个用 C 语言实现的 HTTP Web Server,一个完全的Web服务器。
&&&&&&& Tomcat7始于2010年,最初的版本是7.0.0beta,在日发布的Tomcat 7.0.6已经成为稳定版本,这是Tomcat 7分支的第一个稳定版本,用来取代2007年2月发布的Tomcat 6,Tomcat7修复大量的原有bug,包括其中各个模块,如Catalina,Coyote,Jasper等,其中包括一些比较严重的如内存泄露问题,线程安全问题等。
&&&&&&& 三、Tomcat7下实现动态部署
&&&&&&& Tomcat通过自带的Web应用程序manager来实现对容器中的Web应用程序目录或是WAR文件进行动态部署。
&&&&&&& 1. manager权限设置。
&&&&&&& 由于版本的更新,Tomcat7和6相比较,在权限配置方面变的更细微,原来Tomcat6中的manager应用程序的权限在7中被细分为4种,这些权限的名字都被定义在Tomcat7提供的manager应用程序目录下的\WEB-INF\web.xml文件中,它们是分别是manager-gui,manager-status,manager-script和manager-jmx,其描述见表1。
&&&&&&& 表1
&&&&&&& 其中HMTL接口包含manager应用中的图形界面,有效能防止跨站点伪造请求(Cross-Site Request Forgery,CSRF)的攻击,但是text和JMX就不具备这样的能力。text接口通过查询字符串的方式在地址栏用manager支持的指令管理容器内的Web应用程序。这里以manager-gui为例,来看一下web.xml文件中权限的设置和角色的声明,代码如下:
&&&&&&& &security-constraint&
&&&&&&& &web-resource-collection&
&&&&&&& &web-resource-name&HTML Manager interface (for humans)&/web-resource-name&
&&&&&&& &url-pattern&/html/*&/url-pattern&
&&&&&&& &/web-resource-collection&
&&&&&&& &auth-constraint&
&&&&&&& &role-name&manager-gui&/role-name&
&&&&&&& &/auth-constraint&
&&&&&&& &/security-constraint&
&&&&&&& MemoryRealm是域(Realm)的一种,用来读取保存在\conf\tomcat-users.xml文件中的角色和用户名、密码的关联信息。
&&&&&&& 在tomcat-user.xml文件中配置角色和管理用户的代码如下:
&&&&&&& &role rolename=&manager-script&/&
&&&&&&& &role rolename=&manager-gui&/&
&&&&&&& &role rolename=&manager-jmx&/&
&&&&&&& &role rolename=&manager-status&/&
&&&&&&& &user username=&admin-proxy& password=&s3cret& roles=&manager-gui,manager-script,manager-jmx,manager-status &/&
&&&&&&& tomcat-users.xml文件可以设置不同的角色,使用这些角色名和权限的前提条件是在包含它们的Web应用程序目录下的web.xml中声明。
&&&&&&& 当完成上述操作之后,便可以通过浏览器打开tomcat的欢迎界面,选择&Manager App&入口,把tomcat-users.xml文件中自定义的用户名和密码在弹出的登录对话框中输入,即进入tomcat7中的manager应用中,动态的配置当前tomcat容器中所有被部署的Web应用程序,包括manager本身。
&&&&&&& 2.图形化的动态部署。
&&&&&&& 完成Tomcat7中manager应用的权限配置后,在命令提示符下启动Tomcat服务器,在浏览器中输入http://localhost:8080进入Tomcat的欢迎界面,选择&Manager App&入口,在弹出的用户名和密码对话框中输入tomcat-users.xml配置好的用户名和密码,则可以进入图形化动态部署模式。
&&&&&&& 图形化部署模式提供下列9种功能:
&&&&&&& & 通过直接指定WAR文件,部署一个新的Web应用程序
&&&&&&& & 通过在服务器文件系统中指定Web应用程序的上下文路径来部署一个新的应用
&&&&&&& & 提供服务器中当前被部署的所有Web应用程序列表和这些应用中被激活的会话信息
&&&&&&& & 通过对\WEB-INF\classes和\WEB-INF\lib目录中文件的监视和反射,重新加载容器中已存在的Web应用程序&
&&&&&&& & 提供当前操作系统和Java虚拟机的属性列表
&&&&&&& & 提供可用的全局可用的JNDI资源列表,在部署工具中通过在&Context&部署描述符中嵌入&ResourceLink&元素即可访问JNDI资源&
&&&&&&& & 启动已经停止的Web应用程序
&&&&&&& & 停止正在运行的Web应用程序
&&&&&&& & 卸载已经部署的Web应用程序,并删除其根目录的文档
&&&&&&& 图形话部署模式可以是开发人员方便快捷对Web应用程序进行部署,并对容器中存在的应用进行管理。
&&&&&&& 3.指令化的动态部署。
&&&&&&& 除了图形化的部署方式外,manager应用程序还提供指令化的动态部署模式。指令化的部署实际上是在地址栏通过text接口输入部署的指令和参数即可实现指令化的部署模式,所有manager已知的指令通过在独立的请求URI指定而被执行。
&&&&&&& 指令化的动态部署模式URI格式如下:
&&&&&&& http://{host}:{port}/manager/text/{command}?{parameters}
{command}代表manager应用下程序员需要执行的指令,{parameters}表示针对URI中的指令提供的查询参数。
manager中常用指令如下:
&&&&&&& list:提供Tomcat容器中当前Web应用程序列表
&&&&&&& reload:重新加载Web应用程序
&&&&&&& serverinfo:服务器信息
&&&&&&& sessions:会话管理
&&&&&&& start:启动Web应用程序
&&&&&&& stop:停止Web应用程序
&&&&&&& deploy:部署新的Web应用程序
&&&&&&& undeploy:卸载存在的Web应用程序
&&&&&&& 这些指令有些可以单独使用,如list,而大部分需要使用&?&连接参数一起使用,manager应用提供的参数包括path、version、war等。
&&&&&&& 本文主要阐述deploy指令部署新的Web应用程序。
&&&&&&& 通过Web应用程序上下文部署
&&&&&&& http://localhost:8080/manager/text/deploy?path=/foo
&&&&&&& 其中Web应用程序的上下文通过path参数指定为/foo。
&&&&&&& 通过URL部署Web应用程序目录
&&&&&&& http://localhost:8080/manager/text/deploy?path=/footoo&war=file:/path/to/foo
&&&&&&& 其中Web应用程序的上下文通过path参数指定为/footoo,程序目录则通过war参数指定,由于部署的是文件目录,所以需要指定文件协议file。
&&&&&&& 通过URL部署WAR
&&&&&&& http://localhost:8080/manager/text/deploy?war=jar:file:/path/to/bar.war!/
&&&&&&& 使用URL部署WAR的特殊之处在于需要把jar和file连接使用,并且WAR文件不能在URL中以扩展名war结束,需要在之后添加&!/&。
&&&&&&& 通过Host appBase部署Web应用程序目录
&&&&&&& http://localhost:8080/manager/text/deploy?war=foo
&&&&&&& Host appBase表示服务器的应用程序跟目录,在Tomcat中即为webapps,使用这种方式部署需要事先把Web应用程序目录拷贝到appBase中,不需要指定应用程序的上下文,直接提供Web应用程序在appBase下的相对路径即可。
&&&&&&& 通过Host appBase部署WAR
&&&&&&& http://localhost:8080/manager/text/deploy?war=bar.war
&&&&&&& 和部署目录方式一致,通过Host appBase部署WAR时,事先要把WAR文件拷贝到appBase目录下,然后使用war参数直接指定WAR文件即可。
&&&&&&& 四、总结
&&&&&&& Tomcat7作为一款灵巧的HTTP服务器,最新版本已经提供了对Servlet3.0和JSP2.3的支持。通过Tomcat7提供的动态部署方式能够简单快速的对Web应用程序进行部署,使用图形化的模式直观且方便,并且可以轻松的对容器中已经部署的Web应用程序和会话进行管理;指令化的模式能够让程序员以更快捷的方式对Web应用程序进行部署和卸载,前提是熟悉manager下的指令和参数。
参考文献:
[1]维基百科.Apache Tomcat.2013-6.[DB/OL]http://zh.wikipedia.org/wiki/Apache_Tomcat
[2]孙卫琴. Tomcat与Java Web开发技术详解(第2版).电子工业出版社[M].2009-1。
[3] Budi Kurniawan著. 曹旭东译. 深入剖析Tomcat.机械工业出版社[M].2012-1。
您可能感兴趣的其他文章
&&站长推荐
&&期刊推荐
&&原创来稿文章
&&网络读者服务
转寄给朋友
朋友的昵称:
朋友的邮件地址:
您的邮件地址:
写信给编辑
您的邮件地址:}

我要回帖

更多关于 tomcat7新特性 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信