Access Server Files and directories using WebLogic -Directory -listing
Sometimes, we may have a requirement to access the server files, directory and others files on the server . One such requirement is user wants to access the WebLogic server log files but he does not possess read or write access to the machine. WebLogic provides a handy way to access the files and directories over HTTP.
To achieve the directory listing, We need to create a simple java web project and add a weblogic.xml under the WEB-INF directory. We don’t have to write any java class or any jsp file here. The Final project structure is look like below,
Project >> WEB-INF >> web.xml
Project >> WEB-INF >> weblogic.xml
Project >> index.html
In this section, we are going to create this web application that lists my below directories.
The project zip file: public_html
1. Create a java web project using Eclipse or Jdeveloper
2. Create weblogic.xml and place it under WEB-INF directory
Use the weblogic.xml file mentioned below as a reference and modify the virtual-directory-mapping as per your requirement.
The ‘virtual-directory-mapping‘ in where I have listed my two directories.
Make the ‘index-directory-enabled‘ to true . If you not set this element, you will get 403 Forbidden exception
The ‘context-root‘ is the context path of your URL. For example http://HOST/filedrive.
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/we
3. Create an index.html
I have created this html file for visualization, It has two URL. Each url is dedicated to a directory.
Note: the ‘href’ tag in this page and ‘url-pattern‘ in weblogic.xml should match.
<%@ page contentType="text/html;charset=windows-1252"%>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
<h1>>My File Paths </h1><br/>
<a href="Oracle_Home/">Oracle Home</a><br/>
4. Make the project as war file and deploy it in WebLogic server.
I have used eclipse to create and deploy this project into WebLogic server.
5. Test the URL in browser
Once I deployed the war file into the WebLogic server, i could access it through the URL by http://HOSTNAME:PORT>/CONTEXT_ROOT.
My project rendered in the browser like below, On clicking on each link , the page will redirect to the corresponding directory.In the below screenshot, I have clicked the URL ORACLE_HOME
The page is redirected and displaying the directories inside C:\Oracle\Middleware\Oracle_Home\
The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.
Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
Latest posts by Govind (see all)
- Primavera Error: The database is not setup to use the authentication mode selected: WebSSO:LDAP - June 22, 2017
- Primavera P6 professional Login alert box:The database has not been configured to run background jobs. To correct this error contact your system administrator - June 22, 2017
- How to integrate Oracle BI Publisher and LDAP in WebLogic server - June 21, 2017