Tuesday, November 20, 2012

How to Create Virtual Directory in Weblogic Server

Hi,

You can host your static files like images, javaScript, CSS content to Weblogic server as well. In ideal world these files usually are part of web server but in the absense of HTTP web server like Apache, IIS we can use Weblogic server to host these files.

The benefit of keeping file like that is that all your project's static files like logos, bullets etc etc will reside on OS and in case of any changes all you need to change at OS level instead of application server level.

In summary we will  create a simple app which will use the '/images' context of WLS and all we need to do in our apps to use /images context to retrieve the image.

1. Create a folder on your OS and put all your static images files there
e.g. c:\Jdeveloper\sharedLibs\images\





2. Create Application called 'VirtualDirectoryApp' using Fusion Template

3. Delete Model Project by right clicking it and Click New on ViewController Project and Create weblogic deployment description this will create weblogic.xml file





4. Set the properties of Directories weblogic.xml as shown in the slide



5. Set the context of the application to /virtual



6. Now deploy the WAR file by right clicking the ViewController Project and call the content of directory via following URL

http://myserver:myport/virtual/imagename.jpg





Happy Jdeveloping,
Zeeshan Baig
Follow me on Twitter @baigsorcl
 

No comments:

Post a Comment