0% found this document useful (0 votes)
207 views3 pages

Serving Static Content On WebLogic and GlassFish

This document discusses how to serve static content on Oracle WebLogic and Oracle GlassFish servers. It provides instructions for creating a simple WAR file that can be deployed to either application server. The WAR file contains deployment descriptors that specify the context path and location of the static resources on disk. When deployed, this allows the static content to be served from outside the WAR archive, improving performance by eliminating the need to package all files into the WAR. Specific elements are defined in the WebLogic and GlassFish deployment descriptors to configure the context path mapping and file system location of the static resources.

Uploaded by

chiefu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
207 views3 pages

Serving Static Content On WebLogic and GlassFish

This document discusses how to serve static content on Oracle WebLogic and Oracle GlassFish servers. It provides instructions for creating a simple WAR file that can be deployed to either application server. The WAR file contains deployment descriptors that specify the context path and location of the static resources on disk. When deployed, this allows the static content to be served from outside the WAR archive, improving performance by eliminating the need to package all files into the WAR. Specific elements are defined in the WebLogic and GlassFish deployment descriptors to configure the context path mapping and file system location of the static resources.

Uploaded by

chiefu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

10.2.

2014

Serving Static Content on WebLogic and GlassFish | cdivilly

cdivilly
APPLICATIONEXPRESS,GLASSFISH,WEBLOGIC

ServingStaticContentonWebLogic
andGlassFish
POSTEDBYCDIVILLYJUNE21,2012
FILEDUNDER APPLICATIONEXPRESS,GLASSFISH,LISTENER,STATICCONTENT,
WEBLOGIC
BothOracleWebLogicandOracleGlassFishprovidemechanismstomixinstaticcontentlocatedoutside
aWebApplicationArchive(WAR).WecanleveragethesefacilitiestocreateasimpleWARthatcanbe
usedoneitherWebLogicorGlassFishforservingstaticcontent.
ThisprovidesaneasiertouseapproachforservingOracleApplicationExpressstaticresourceswhenusing
Oracle Application Express Listener, compared to zipping all the Application Express resources into a
largeWAR.Anaddedbenefitofthisapproachisthatchangeswithinthestaticresourcesfolderarepicked
upimmediately,noneedtorestartorupdatetheWAR.
Letsgetstarted,weregoingtocreateasmallWARthatcontainsthenecessarydeploymentdescriptors.
Firstcreateafoldertoworkin.
1
2
3
4

mkdirstatic
cdstatic
mkdirWEBINF
cdWEBINF

NowcreatetheJEEWARdescriptor,named:web.xmlwiththefollowingcontents:
1
2
3
4
5

<?xmlversion="1.0"encoding="UTF8"?>
<!DOCTYPEwebappPUBLIC
"//SunMicrosystems,Inc.//DTDWebApplication2.3//EN"
"http://java.sun.com/j2ee/dtds/webapp_2_3.dtd">
<webapp/>

NextcreatetheWebLogicspecificdeploymentdescriptor,named:weblogic.xml with the following


contents:
1
2
3
4
5
6
7

<weblogicwebappxmlns="http://www.bea.com/ns/weblogic/weblogicw
<!Thiselementspecifiesthecontextpaththestaticresources
<contextroot>/i</contextroot>
<virtualdirectorymapping>
<!Thiselementspecifiesthelocationondiskwherethestati
<localpath>/path/to/apex/images</localpath>
<urlpattern>/*</urlpattern>

http://cdivilly.wordpress.com/2012/06/21/serving-static-content-on-weblogic-and-glassfish/

1/3

10.2.2014

8
9

Serving Static Content on WebLogic and GlassFish | cdivilly

</virtualdirectorymapping>
</weblogicwebapp>

Notethevaluesofthecontext-rootandlocal-pathelements,adjustthesevaluestomatchyour
requirements.
Next create the GlassFish specific deployment descriptor, named: sun-web.xml with the following
contents:
1
2
3
4
5
6
7
8

<?xmlversion="1.0"encoding="UTF8"?>
<!DOCTYPEsunwebappPUBLIC"//SunMicrosystems,Inc.//DTDGlass
<sunwebapp>
<!Thiselementspecifiesthecontextpaththestaticresources
<contextroot>/i</contextroot>
<!Thiselementspecifiesthelocationondiskwherethestatic
<propertyname="alternatedocroot_1"value="from=/*dir=/path/to/a
</sunwebapp>

Note the valuesofthe context-root element and the dir field within the value attribute of the
propertyelement,adjustthesevaluestomatchyourrequirements.
NextcreatetheWARfromthesefiles:
1
2

cd..
jarcvf../static.war.

Finallydeploythestatic.warfiletoyourWebLogicorGlassFishserver.
OnepointtonoteiswhenusingtheAdministrationUIinGlassFishtodeploytheWAR,thecontextroot
fieldisautofilledbytheUIbasedonthenameoftheWAR.Clearthecontentsofthisfieldtoensurethe
context-rootvaluespecifiedinthesun-web.xmlisused.
Abouttheseads

Discussion

Commentsareclosed.

cdivilly
BlogatWordPress.com.TheMorningAfterTheme.
Follow
http://cdivilly.wordpress.com/2012/06/21/serving-static-content-on-weblogic-and-glassfish/

2/3

10.2.2014

Serving Static Content on WebLogic and GlassFish | cdivilly

Followcdivilly
PoweredbyWordPress.com

http://cdivilly.wordpress.com/2012/06/21/serving-static-content-on-weblogic-and-glassfish/

3/3

You might also like