Websphere 8 Application & Static Content

By | December 1, 2016

I just migrated an application to Websphere and wanted to serve some static files (.jar, .jsp, .cfg, etc.) from the same context root as my application.

I used the ExtendedDocumentRoot feature to serve static content from a directory located outside of my applications directory structure.

https://www.ibm.com/support/knowledgecenter/SSCKBL_8.5.5/com.ibm.websphere.nd.doc/ae/rweb_jspengine.html

I eventually settled on this solution:

Create a file called ibm-web-ext.xmi in the WEB-INF directory of the application.

<webappext:WebAppExtension xmi:version="2.0"
	xmlns:xmi="http://www.omg.org/XMI" xmlns:webappext="webappext.xmi"
	xmlns:webapplication="webapplication.xmi" xmi:id="WebApp_ID_Ext"
	reloadInterval="10" reloadingEnabled="true" fileServingEnabled="true"
	directoryBrowsingEnabled="false" serveServletsByClassnameEnabled="false"
	preCompileJSPs="false">
	<webApp href="WEB-INF/web.xml#WebApp_ID" />
	<fileServingAttributes xmi:id="FSA_1"
		name="extendedDocumentRoot" value="${CONTENT_DIR}" />
	<jspAttributes xmi:id="JSA_1" name="extendedDocumentRoot"
		value="${CONTENT_DIR}" />
</webappext:WebAppExtension>

The fileServingEnabled property wasn’t really necessary as the default value is true but I included it for clarity.
The fileServingAttributes element sets the directory to use for static files (not .jsp).
The jspAttributes element sets the directory to use for JSP files.

The ${CONTENT_DIR} property should be defined as an Websphere variable (you can specify different values for each node). The directory doesn’t have to be a variable it could be a relative or fully qualified path. Multiple directories can be specified using a comma separated list.

websphere

Leave a Reply

Your email address will not be published. Required fields are marked *