Search code examples
weblogic

Link to file outside context root of weblogic


If I want to display an image in my webpage and its src is a file outside context root. At the IDE, the image is shown to be loaded.

But when I test the web page, nothing displayed. How can I config weblogic server to allow the image to be displayed. If not is there anyway to run around this problem.

Thanks a lot.


Solution

  • You can use the Virtual Directory Mapping feature (that you declare in the weblogic.xml):

    Using the virtual directory mapping feature, you can create one directory to serve static files such as images for multiple Web Applications. For example, you would create a mapping similar to the folowing:

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

    A request to http://localhost:7001/mywebapp/images/test.gif will cause your WebLogic Server implementation to look for the requested image at: c:/usr/gifs/images/*.

    This directory must be located in the relative uri, such as "/images/test.gif".