Use WebSphere extensions to define virtual directory mappings

The WebLogic virtual directory mapping allows an application to serve files such as images or static files that are located outside the document root of the application. You can use the WebSphere file-serving features to serve these files. This rule detects the presence of the <virtual-directory-mapping> element in the weblogic.xml file. The automated fix will be able to help you create corresponding <fileServingAttributes> elements in the WebSphere traditional or Liberty web extension file.

For example, the weblogic.xml file can contain the following mappings:

<virtual-directory-mapping>
<local-path>c:/usr/files</local-path>
<url-pattern>/images/*</url-pattern>
<url-pattern>*.jpg</url-pattern>
</virtual-directory-mapping>

You can define the same information in the WebSphere Application Server web extensions as shown in the following example:

<fileServingAttributes xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="c:/usr/files"/>
<fileServingAttributes xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/* *.jpg"/>

The extendedDocumentRoot file serving attribute is a comma-delimited string for more than one root that exists outside of the application web module.

The file.serving.patterns.allow file serving attribute is a space-delimited string for more than one pattern.

You might experience problems serving content from applications with static content in multiple locations. In WebLogic any defined virtual-directory-mapping is available from both the context root and the directory location. In WebSphere Application Server the file.serving.patterns.allow property limits access to static contents that match the specified patterns within the extended document root or the context root.

Depending on how your files are organized, you might need to modify the file.serving.patterns.allow property value. For example,

<fileServingAttributes xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="/common/files"/>
<fileServingAttributes xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/*"/>

If you have an images directory in /common/files and a /common/files/images in the context root, add a /common/files/images to the file.serving.patterns.allow property value.

<fileServingAttributes xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="/common/files"/>
<fileServingAttributes xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/* /common/files/images/*"/>

You can allow wider access to files using the setting in the following example, but using this setting might allow more content to be available to the application than you intend.

<fileServingAttributes xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="*"/>

For more information and examples, see the following resources: