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.


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"
	<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}" />

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.


Leave a Reply

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