X

This blog introduces how to diagnose Agile PLM related issues.

  • March 10, 2015

Weblogic URL Redirect to Context Path

Jie Chen
Senior Principal Technical Support Engineer

To visit web application deployed in Weblogic, we usually access it through its context path like http://server/myapp . But many people expect the URL to be friendly and short enough as http://server only. Here is a very simple solution, deploy a separate simple web application with root context-root to achieve.

Note: this is not related to term of Proxy or Load Balancer.

A simple web application (say DummyApp) demonstrates the solution with following

weblogic.xml

To access this DummyApp, we have to input URL http://server/DummyApp . W can context-root as below to make it accessible through http://server only. That is to say, if access http://server , browser will redirect the request to http://server/DummyApp because we define it as the default application.

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<context-root>/</context-root>
</weblogic-web-app>

web.xml

A very simple web.xml to have a default welcome page index.html.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>dummyWeb</display-name>

<welcome-file-list>

<welcome-file>index.html</welcome-file>

</welcome-file-list>
</web-app>

index.html

A simple static HTML page to redirect DummyApp to http://server/myapp , using HTML meta with the http-equiv parameter set to "refresh".

<html>
<head>
<meta http-equiv="refresh" content="0;url=/myapp">
</head>
</html>


How it works

When we access http://server, Weblogic will redirect our request to its default application DummyApp's index.html, that is http://server/DummyApp/index.html . And index.html immediately routes to http://server/myapp as we expect.


Join the discussion

Comments ( 1 )
  • Firoz Tuesday, January 30, 2018
    working on Java Spring
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.