Post date: Nov 10, 2015 4:57:44 PM
If you run the SMCP program on a single server, and simply give your users links to that server, you may not need the extra complexity of the 'Initiating URL'. But if you run more than one server, or just need to change servers quickly, here's how it would be used.
For example: if you have a main server and a secondary, 'emergency' server that you need to switch people to quickly, it's sometimes clumsy to send out new links to every user, especially if they've already built them all in their browser.
So you might want to give everyone a link to a single, permanent server, and let THAT server redirect them to whichever web server you want to use at the moment. If your main server goes down, you can just modify the link in your 'initiating' server and then it will point to your backup web server. But the users can continue to use the same link, and you won't have to scramble around to each user, updating their links - temporarily - until the main server is back.
You can accomplish all this without using the 'Initiating URL', but without it, your Quick Links won't know to point back to the 'initiating' server. So that's where the 'initiatingURL' setting in the web.xml file comes in - that tells the SMCP program to point the quick links back to the 'initiating' server:
Here's an example:
Let's say your main server is called 'main.com', running tomcat on the regular HTTP port (80) and your backup is called 'backup.com' running tomcat on port 8080. You may want to be able to easily switch between them.
You can set up the 'initiating URL' anywhere - it could be on a third server called 'initiating.com'.
The 'permanent link' would actually point users to a page called 'smcp.html' on the 'initiating' server ('initiating.com') - and that page might look like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
<HEAD>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="CACHE-CONTROL" content="NO_CACHE">
<META http-equiv="EXPIRES" CONTENT="0">
//This sets a 'shortcut icon' for the web site, if desired
<link rel="shortcut icon" href="SMCP16.ico" type="image/x-icon" />
<script type="text/javascript">
//This function allows us to use one, permanent link, which will always point to this page,
// but from here, we can redirect the user to a different server, depending on the database
// code that is contained in their link:
function delayedRedirect(){
var sServerURL = '';
// This is a list of the possible servers they may be running the program on:
var sMainServerURL = 'http://main.com/';
var sBackupServerServerURL = 'http://backup.com.com:8080/';
//Replace the question marks to redirect properly:
// The query string will contain the module/class that is being called, so we have to strip that off
// and format it for the ultimate target server.
var windowlocationsearch = window.location.search.replace('?', '');
windowlocationsearch = windowlocationsearch.replace('%3F', '?');
//Send them to the main server or the backup by changing this line when needed:
sServerURL = sMainServerURL;
//Now forward the user to the new location:
window.location = sServerURL + windowlocationsearch + window.location.hash;
}
</script>
</HEAD>
<!-- This creates a 1 second pause for the user to see the 'redirecting message' below -->
<BODY onLoad="setTimeout('delayedRedirect()', 1000)">
<h2>Redirecting you to the live server...</h2>
</BODY>
</HTML>
Finally, your 'initiatingURL' entry in web.xml would look like this:
<context-param>
<param-name>initiatingurl</param-name>
<param-value>http://initiating.com/smcp.html</param-value>
<description>
The link to the 'initiating' server, which is used to create quicklinks, etc.
</description>
</context-param>