How to Publish Multiple Websites Using a Single Tomcat Web Application

How to Publish Multiple Websites Using a Single Tomcat Web Application

Registering A Domain Name

Originally, Knowledge Folders was hosted on a static IP at Indent, Inc. With potential changes to internal IP, I decided to get a proper domain address for Knowledge Folders.



I went to GoDaddy.com on the advice of a friend. I found it had excellent support and its prices seemed very cheap. I registered three domains in the process:

knowledgefolders.org

knowledgefolders.net

knowledgefolders.com

Registering these domains was quite simple at GoDaddy, but setting up the rest took some work. Knowledge Folders was physically hosted with Indent at Peak 10, a hosting facility, on a dedicated Windows server, whereas the domain names were registered at GoDaddy.

Securing The Name Servers and Setting Up IP Address Association

To make the domains work, the first thing I needed to know from Peak 10 was the name servers that would be used to resolve the host names. I needed two name servers. For instance, the name servers for Peak 10 are:

NS1.JAX.PEAK-10.COM

NS1.CLT.PEAK-10.COM

The next step was to tell the Peak 10 staff the domain names I'd registered and the physical IP address the host names should be pointing to. With these changes, I was able to access Knowledge Folders with all of the domain names.

Changes to Knowledge Folders

Thus, I was able to take multiple domain names and point them to the same web app on a given physical IP. So for instance, when I accessed http://www.satyakomatineni.com, I was taken to the home page of Knowledge Folders.

But my intention was to go to the homepage of the account identified by the userid of satya. This required changing two things in Knowledge Folders:

  • index.jsp
  • some new definitions in the properties files

The general idea was to have the index.jsp identify the incoming host name and, provided that there was a way to associate the domain name to an account, the index.jsp would transfer control to the home page of that account.

Example index.jsp and Properties File

The source code of index.jsp that accomplishes this is as follows

<!--

*************************************************************

* Sample code for knowing the Knowledge Folders url:

* Standard aspire libraries

*************************************************************

-->

<%@ page import="com.ai.htmlgen.*" %>

<%@ page import="com.ai.application.utils.*" %>

<%@ page import="com.ai.common.*" %>



<!--

*************************************************************

* html header

*************************************************************

-->

<html><head>

<title>Welcome to Aspire Knowledge Center</title>

<link rel="stylesheet" type="text/css" href="/akc/style/style.css">

<script src="/akc/js/genericedits1.js"></script>



<!--

*************************************************************

* Figure out home page, 

* if not found use the main home page of Knowledge Folders

*************************************************************

-->

<%

   String hostname = request.getServerName();

   String homepageurl = AppObjects.getValue("aspire.multiweb." 

                        + hostname + ".homepageurl",null);

   String targeturl = "";

   if (homepageurl == null)

   {

      targeturl = "/akc/akchome.html";

   }

   else

   {

      //hostuserid exists

      targeturl = homepageurl;

   }

   String debug = request.getParameter("debug");

%>

<script>



<!--

*************************************************************

* gotoHomePage() on load

*************************************************************

-->

function gotoHomePage()

{

   debugAlert("gethost on the client side:" + getHost());

   debugAlert("<%=hostname%>:<%=homepageurl%>");

   var targeturl = "<%=targeturl%>";

   debugAlert(targeturl);

   document.location.replace(targeturl);

   

}

<!--

*************************************************************

* some debugging support

*************************************************************

-->

function debugAlert(message)

{

   var debug = "<%=debug%>";

   if (debug == "true")

   {

      alert(message);

   }

}

</script>

</head>

<!--

*************************************************************

* onload

*************************************************************

-->

<body onload="gotoHomePage()">

</body></html>

Here is the Aspire/J2EE configuration file to support the "domain name to account" translation or mapping:

aspire.multiweb.www.satyakomatineni.com.userid=satya

aspire.multiweb.www.satyakomatineni.com.homepageurl=\

/akc/update?request_name=GotoHomepageURL&ownerUserId=satya

Prev  [1] [2] [3] Next

Close    To Top
  • Prev Article-Java:
  • Next Article-Java: None
  • Now: Tutorial for Web and Software Design > Java > Java Servlets > Java Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction