IIS6与Tomcat6 整合

本文详细介绍了如何使用Jakarta Tomcat Connector将IIS 6与Tomcat 5进行整合,实现通过IIS访问Tomcat上的JSP应用。包括安装配置步骤、常见问题解决方法及安全性注意事项。

Kit.Liao 荆棘鸟设计 www.kingkit.com.cn

荆棘鸟刚买了vps,环境都得自己搭建。由于服务器同时运行asp与jsp,所以必须整合IIS与TOMCAT。

环境:Windows 2003,JDK 1.6,IIS 6,TOMCAT6,isapi_redirect-1.2.14.exe

JDK,IIS,TOMCAT怎么安装我不多说了。在IIS,TOMCAT可以正常运行web应用的前提下,我们来用JK搭通IIS与TOMCAT的天地线!

1.TOMCAT新建一个名叫test的站点,启动TOMCAT,确保能运行该站点。

2.把isapi_redirect-1.2.14.exe安装,这个安装也很简单,一路NEXT就行。我的安装路径是:C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector
下面有这几个目录。

3. 右键“我的电脑”-->-管理->服务和应用程序-->Internet信息服务(IIS),右键点击默认站点的属性页面,选择ISAPI过滤器选项卡,看看有没名为Jakarta的Jakarta Isapi Redirector,如果没有的话,就添加一个筛选器,名为jakarta,可执行文件选择刚才我们安装好的Jakarta目录下的bin的isapi_redirector.dll,确定可用。

 

4.打开Jakarta Isapi Redirector安装目录下conf文件夹中的uriworkermap.properties,在其中添加一个你需要通过IIS运行的JSP站点的名称(该站点需要在TOMCAT下的webapps目录下,并运行良好),比如:该站点名称为test,则需要加入/test/*=wlb。

5.打开IIS管理端,点击WEB扩展服务,新建一个扩展服务,其名称建议为Jakarta,浏览Jakarta Isapi Redirector安装目录下的bin,选择isapi_redirect.dll。并允许这个服务的运行。

5.重启IIS(右键“我的电脑”-->-管理->服务和应用程序-->服务,找到IIS Admin,重新启动)

6.http://localhost/test/....

如果http://localhost:8080/test/....http://localhost/test/....运行的结果一样,恭喜你!

如果有问题,也可参考一下这文章http://www.cflex.net/showFileDetails.cfm?ObjectID=296&Object=File&ChannelID=1

Connect IIS 6 to Tomcat 5

 

I needed to set up a simple distributed system consisting of an outward facing, secured IIS 6 web server and an internal, dedicated Flex server running under Tomcat 5. There is a lot of documentation out there but that in itself is a problem. It is difficult to know what really applies and what is out of date. I just successfully set up several such systems using the Tomcat <==> IIS connector. Following are the steps I took, and comments and tips about what I have learned.

 

Here is a link to the connector documentation index, if you want to do this the hard way:

http://jakarta.apache.org/tomcat/connectors-doc/

 

First the problem in a nutshell:

You can happily call your Flex applications from an IIS application (like ASP.NET) on an internal development system by using the host name (or IP address) and the port number. For example, in a custom wrapper this will work: http://myFlexServer:8080/flex/myApp/myFile.mxml. However, if you try to use that custom wrapper from outside the firewall, in other words, from the internet, you will find that port 8080, and most others, are blocked, and you cannot access your Flex application.

 

One solution is a "Jakarta Tomcat Connector", which directs calls to your Flex app through the IIS web server to the Flex/Tomcat server. You can do the same this with JRUN, and, I suspect, other J2EE servers as well. This connector allows you to use the IIS web server in the URL  to the Flex app, without requiring any port specifications to gag the firewall. So the URL  to a Flex app like in the example above becomes: http://www.myIISWebServer.com/flex/myApp/myFile.mxml.

 

How does a “connector” work? There are IIS and Tomcat parts. The Tomcat side is already set up for you in ...\Tomcat 5.0\conf\server.xml, whose job it is to create Tomcat "listeners" on specified ports. It sets up the normal listener on, for example, port 8080, but it also sets up a special listener on port 8009. In fact, if you have the Tomcat log level set to "Info" (the "Monitor Tomcat" menu/dialog, logging tab), you can look in the log: ...\Tomcat 5.0\logs\stdout.log, and see the line: "INFO: JK2: ajp13 listening on /0.0.0.0:8009"

 

But you can really just trust me, it is there.

 

On the IIS side, the connector works by using an "ISAPI" filter. This "filter" watches URL s for certain "contexts", and passes those contexts on to the specified handler dll. The simplest "context" is one of the folders under the Tomcat "webapps" folder. For example, /flex/, and /samples/ (yes, these are the folders you think) are Tomcat contexts in a default flex install.

 

Setting up IIS to use Tomcat connector

You actually have to do some work now, but not as much as you would think by reading the documentation.

 

Note: You want to be working with the “JK” connector, NOT the JK2 connector, which has been deprecated. Never mind that the log shows JK2, or that there is a jk2.properties file in the Tomcat\conf folder, and that a google search will turn up a lot of people still using JK2.

 

First, obtain the connector installer: isapi_redirect-1.2.14.exe It is available from several locations including:

http://www.devlib.org/apache/jakarta/tomcat-connectors/jk/binaries/win32/jk-1.2.14/

 

Now run the install. There does not appear to be any documentation for the installer, but here is a link to a document that describes the manual method of what the installer does, plus troubleshooting and general info, just FYI.

           http://jakarta.apache.org/tomcat/connectors-doc/howto/iis.html

 

Briefly, the install creates a folder structure and adds a few files to it, sets some registry entries, creates an IIS virtual directory, adds the isapi_redirect.dll to the IIS website ISAPI filters tab. It should take care of all the steps listed in the above howto document under "Configuring the ISAPI Redirector".

 

Next add a Web Service Extension. This needs to be done manually because the install works for IIS 5 and 6, but “Web Service Extension” only applies to IIS 6.

· Open the … Administrative Tools, Internet Information Services console.

· In the tree on the left, click ” Web Service Extensions”

· In the right hand pane, click “Add a new Web Service Extension”

· For the Extension Name, enter: Jakarta Tomcat

· Click the “Add” button.

· Browse and select C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\bin\isapi_redirector.dll

· Click the “Allow” button. DO NOT MISS THIS STEP!

· From the “Services” MMC, restart “IIS Admin”

 

Now, the install defaults to looking for a Tomcat listener on localhost. If your Tomcat is on a different server, as mine was, you will need to make a simple edit.

 

On the IIS web server, edit:

C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\workers.properties.minimal

 

Change the line that says:

           worker.ajp13w.host=localhost

To:

           worker.ajp13w.host=www.myIISWebServer.com

You can also use an IP address. I do not know if a machine name will work.

 

Restart IIS.

 

At this stage we can test the tomcat examples, using this URL :

           http://www.myIISWebServer.com/jsp-examples/index.html

 

If it loads we are good to continue. If not, you will need to look at the troubleshooting section of the howto/iis.html document.

 

If we are good to continue, we will next add the flex “context”. The following assumes a default Flex install, with your application in:

...\Tomcat 5.0\webapps\flex

 

Adding the "flex" context:

On the IIS web server, edit:

C:\Program Files\Apache Software Foundation\Jakarta Isapi Redirector\conf\uriworkermap.properties

 

In the # [URL ]=[Worker name] section, add this line:

           /flex/*=wlb

 

Save the file.

 

Restart IIS.

 

Finally, test the connector with Flex using an URL like this:

           http://www.myIISWebServer.com/flex/myApp/myFile.mxml.

 

 

Security caveat:

In our setup, where the flex app was called from a custom wrapper in a tightly secured ASP.NET application, adding theconnector / isapi redirector had the consequence of breaking the security on the Flex app because it can be called directly from the web.

 

The ideal solution would have been for the Tomcat container’s authorization module to read the ASP.NET forms security token to permit access. Regretfully, I have not been able to make this work yet.

 

Tracy Spratt

 

 


 

 

 

 

 

内容概要:本文系统研究了基于粒子群算法(PSO)的微网优化调度方法,并重点引入需求响应机制以提升微电网运行的经济性可靠性。研究构建了一个综合考虑风能、光伏、储能、柴油发电机、燃气轮机等多种分布式能源的微电网模型,建立了以最小化系统综合运行成本为目标,涵盖燃料成本、环境污染惩罚、购售电费用及需求响应激励成本的多目标优化模型。文中详细阐述了粒子群算法的数学原理及其在求解此类非线性、多维度、带约束的复杂优化问题中的独特优势,通过Matlab编程实现了完整的算法流程仿真分析,验证了所提方法在有效降低系统运行成本、平抑负荷波动、提高可再生能源消纳率以及增强微网应对需求侧变化灵活性方面的显著效果。; 适合人群:具备一定电力系统、优化理论基础和Matlab编程能力的高校研究生、从事新能源、智能电网及相关领域研究的科研人员,以及致力于微电网规划运行优化的工程技术人员。; 使用场景及目标:①用于教学科研,深入理解微网优化调度的核心挑战、数学建模方法及智能优化算法的应用;②为实际微电网项目的规划设计、运行策略制定提供可靠的算法工具和技术参考;③作为智能优化算法(如PSO)在综合能源系统中成功应用的典型案例,推动先进算法在能源互联网领域的研究实践。; 阅读建议:建议读者在学习过程中,务必结合文中的Matlab代码进行上机实践,重点关注目标函数的设计逻辑、各类物理约束(如功率平衡、设备出力、储能容量等)的数学表达,以及PSO算法中关键参数(如种群规模、惯性权重、学习因子)的设置调优技巧,可通过改变参数或扩展模型(如加入更多能源形式或转化为多目标优化)来加深理解和掌握。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值