Novell Home

Redirecting the Access Gateway to the Full Domain Name

Novell Cool Solutions: Tip
By Bart Andries

Digg This - Slashdot This

Posted: 24 Oct 2007
 

Introduction

If web services are configured for an internal network, where all the machines are member of the same DNS domain, you can easily reach all the web services by only specifying the host name in the browser, without specifying the domain name.

The Access Gateway requires you to specify the domain name when trying to reach the accelerated web service - otherwise, you'll receive an error from the Access Gateway. With some easy modifications to the error page, you can redirect a browser that is accessing the web service by specifying only the host name to the full domain name.

Figure 1 - Error: "Host name received is not for this web site"

Setup

For this example, we'll use "nam3-lab.lab.ba" as the full domain name. The host name in the example is "nam3-lab", and the domain name is "lab.ba". This example will show how to modify the error page. It contains some reference code that can be changed according to your preferences.

First, you need to locate the error page. You can find this on the Access Gateway servers in this folder:

/var/opt/novell/tomcat4/webapps/LAGERROR/

The error page is called "error.jsp".

Modification

Use the following three steps to modify the error page:

1. Add Java code to the jsp page to detect if the error is caused by host name mismatch and that the browser is using only host name to connect.

<%
...
String onload = "";
String host = "";
if(statusCode.matches("403") == true)
{
        onload = "";
        host = request.getServerName();
        String isFullName = host.indexOf(".")+"" ;
        if(isFullName.equals("-1") == true)
                {
                        onload = "redirect()";
                }
}
...
%>

2. Add JavaScript to the page to redirect the browser, as shown below.

<SCRIPT LANGUAGE="JavaScript">

</SCRIPT>

The browser will call this script when a redirect to the full domain name is needed. The host name is derived from the browser request, and the domain name is defined statically in the script.

3. Change the body to include the onload event:

<body leftmargin="0" topmargin="0" rightmargin="0" marginheight="0" marginwidth="0" onload="<%=onload%>">

When users now accesses http://nam3-lab, they will be automatically redirected to http://nam3-lab.lab.ba, and the error message will not displayed.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell