湘潭大学j2ee实验报告绝对完整.docx
《湘潭大学j2ee实验报告绝对完整.docx》由会员分享,可在线阅读,更多相关《湘潭大学j2ee实验报告绝对完整.docx(28页珍藏版)》请在冰豆网上搜索。
湘潭大学j2ee实验报告绝对完整
实验一、应用服务器集成
1.整合apache和tomcat
安装apache到c:
\j2ee\Apache中
解压tomcat到c:
\j2ee\Tomcat中
输入测试http:
//localhost/
输入测试http:
//localhost:
8080/
接着关掉Apache和tomcat
然后打开C:
\j2ee\Apache\conf\httpd.conf
去掉如下图红线框中的#符号
在文件最后添加
接下来启动Apache和Tomcat,在C:
\j2ee\Tomcat\apache-tomcat-6.0.44\webapps\ROOT建一个文件名为host,host里面新建一个test.jsp
接着,在浏览器中输入http:
//localhost:
8080/host/test.jsp得到如下页面
在浏览器中输入http:
//localhost/host/test.jsp同样得到如下页面
到此,Apache和tomecat整合成功!
2.Tomcat+ActiveMQ实现消息服务
在jsm-test项目中需要在tomcat的lib中导入
一共导入6个包:
commons-logging-1.1.jar
activemq-core-5.5.0.jar
activemq-web-5.11.1.jar
geronimo-j2ee-management_1.1_spec-1.0.jar
geronimo-jms_1.1_spec-1.1.1.jar
geronimo-jta_1.0.1B_spec-1.0.1.jar
修改文件:
Tomcatconf下的context.xml
--Thecontentsofthisfilewillbeloadedforeachwebapplication-->
--Defaultsetofmonitoredresources-->
WEB-INF/web.xml
--UncommentthistodisablesessionpersistenceacrossTomcatrestarts-->
--
-->
--UncommentthistoenableCometconnectiontacking(providesevents
onsessionexpirationaswellaswebapplifecycle)-->
--
-->
name="jms/FailoverConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMSConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="failover:
(tcp:
//localhost:
61616)?
initialReconnectDelay=100&maxReconnectAttempts=5"
brokerName="localhost"
useEmbeddedBroker="false"/>
name="jms/NormalConnectionFactory"
auth="Container"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMSConnectionFactory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="tcp:
//localhost:
61616"
brokerName="localhost"
useEmbeddedBroker="false"/>
auth="Container"
type="mand.ActiveMQTopic"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TEST.FOO"/>
auth="Container"
type="mand.ActiveMQQueue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MY.TEST.FOO.QUEUE"/>
Activemqconf下的activemq.xml文件
--
LicensedtotheApacheSoftwareFoundation(ASF)underoneormore
contributorlicenseagreements.SeetheNOTICEfiledistributedwith
thisworkforadditionalinformationregardingcopyrightownership.
TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
(the"License");youmaynotusethisfileexceptincompliancewith
theLicense.YoumayobtainacopyoftheLicenseat
http:
//www.apache.org/licenses/LICENSE-2.0
Unlessrequiredbyapplicablelaworagreedtoinwriting,software
distributedundertheLicenseisdistributedonan"ASIS"BASIS,
WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
SeetheLicenseforthespecificlanguagegoverningpermissionsand
limitationsundertheLicense.
-->
--STARTSNIPPET:
example-->
xmlns="http:
//www.springframework.org/schema/beans"
xmlns:
amq="http:
//activemq.apache.org/schema/core"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xsi:
schemaLocation="http:
//www.springframework.org/schema/beanshttp:
//www.springframework.org/schema/beans/spring-beans-2.0.xsd
http:
//activemq.apache.org/schema/corehttp:
//activemq.apache.org/schema/core/activemq-core.xsd
http:
//activemq.apache.org/camel/schema/springhttp:
//activemq.apache.org/camel/schema/spring/camel-spring.xsd">
--Allowsustousesystempropertiesasvariablesinthisconfigurationfile-->
//activemq.apache.org/schema/core"brokerName="localhost"persistent="true"useShutdownHook="false">
--Destinationspecificpoliciesusingdestinationnamesorwildcards-->
"memoryLimit="5mb"/>
"memoryLimit="5mb">
--UsethefollowingtoconfigurehowActiveMQisexposedinJMX-->
--ThestoreandforwardbrokernetworksActiveMQwilllistento-->
--bydefaultjustautodiscovertheotherbrokers-->
//default"/>
--Exampleofastaticconfiguration:
//(tcp:
//host1:
61616,tcp:
//host2:
61616)"/>
-->
--UsethefollowingifyouwishtoconfigurethejournalwithJDBC-->
--
-->
--OrifyouwanttousepureJDBCwithoutajournal-->
--
-->
--Themaximumaboutofspacethebrokerwillusebeforeslowingdownproducers-->
--ThetransportconnectorsActiveMQwilllistento-->
//localhost:
61616"discoveryUri="multicast:
//default"/>
//localhost:
61617"/>
//localhost:
61613"/>
//localhost:
61222"/>
--
**LetsdeploysomeEnterpriseIntegrationPatternsinsidetheActiveMQMessageBroker
**Formoredetailssee
**
**http:
//activemq.apache.org/enterprise-integration-patterns.html
-->
//activemq.apache.org/camel/schema/spring">
--YoucanuseaelementforeachrootpackagetosearchforJavaroutes-->
org.foo.bar
--YoucanuseSpringXMLsyntaxtodefinetherouteshereusingtheelement-->
example.A"/>
example.B"/>
--UncommenttocreateacommandagenttorespondtomessagebasedadmincommandsontheActiveMQ.Agenttopic-->
--
//activemq.apache.org/schema/core"brokerUrl="vm:
//localhost"/>
-->
--AnembeddedservletengineforservinguptheAdminconsole-->
--Thisxbeanconfigurationfilesupportsallthestandardspringxmlconfigurationoptions-->
--PostgresDataSourceSampleSetup-->
--
-->
--MySqlDataSourceSampleSetup-->
--
mysql:
//localhost/activemq?
relaxAutoCommit=true"/>
-->
--OracleDataSourceSampleSetup-->
--
oracle:
thin:
@localhost:
1521:
AMQDB"/>
-->
--EmbeddedDerbyDataSourceSampleSetup-->
--
-->
--ENDSNIPPET:
example-->
Tomcat下webapps\aa项目的web.xml
xmlversion="1.0"encoding="UTF-8"?
>
xmlns="
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xsi:
schemaLocation="