Monday, November 17, 2014

Using WebLogic Server to Simply Store Static Content

A couple of weeks ago I saw a forum thread which I found very interesting. A guy was asking if it's possible or not to use WebLogic as a Web Server, in a similar way than when an index.html file is placed on the 'www' directory of Apache. So I answered him.
Actually you can use WebLogic as a web server, but unlike Apache where you place a html file to the www directory and you can see it immediately, in WebLogic you have to deploy it to a domain. 
  1. The html files (or any other static content like pdf files) must be in a directory of your choice (i.e. C:\testhtml). 
  2. On that directory create a WEB-INF directory (from the example of step 1 it would be C:\testhtml\WEB-INF). 
  3. In the WEB-INF directory create a file called web.xml with the following content:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"""><web-app></web-app>
  4. Login to the WebLogic Console to deploy the application (i.e. http://[your_server]:7001/console ) 
  5. Click on Deployments. 
  6. Click Install and set the path to the directory of step 3 (if the directory only contains the html file and the WEB-INF subdirectory you will see no files to select, but the Next button will be enabled anyway). 
  7. Leave default "Install this deployment as an application" and click Next. 
  8. Select the servers you wish to deploy this. 
  9. Accept the defaults and click Finish. 
  10. Activate Changes if the message appears. 
  11. You should now be able to see the application started in the deployments screen. 
  12. You can now access your static content on the WebLogic Server port via the following URL: http://[your_server]:7001/testhtml/[your_static_file]