URL rewriting for Alias in webserver - webserver

I have two copy of our XYZ Application ( Test, Training). They are two different applications in websphere having two different datatbases. We usually tend to have one webserver per websphere application. Although I know we can have multiple webservers. In my webserver we have created a variable called LoginExternal as shown below which points to a physical folder with the same name in the application server.
Alias /LoginExternal //winxen90/LoginExternal$
We refer to the LoginExternal variable through our HTML as shown below.
<script type="text/javascript" language="JavaScript" src="/**LoginExternal**/Data/LoginAnnouncements.js"></script>
<script type="text/javascript" language="JavaScript" src="/**LoginExternal**/Data/LoginForms.js"></script>
href="JavaScript:LGNEXTUTILS_OpendExternalPage( '/LoginExternal/Pages/LoginAnnouncements.html' );">
The problem we are facing is that with this setup the two applications are forced to use data from one physical folder called LoginExternal because of the webserver alias. I am looking for a solution by which even if we have two physical folders LoginExternal1 , LoginExternal2 one for each application The HTML files from each application should refer to the correct LoginExternal folder. I am hoping we can achieve this by some form of URL rewriting.
Thanks for your help.

I was going to say that this might not be possible without using separate virtual hosts, but...
I think your Rewrite condition can compare the Referrer header against your two web applications' context roots.

Related

Bootstraping OpenUI5 from single JS file

OpenUI5 documentation suggests starting work by using a library loaded from CDN:
<script id="sap-ui-bootstrap"
type="text/javascript"
src="https://openui5.hana.ondemand.com/1.42.6/resources/sap-ui-core.js"
data-sap-ui-theme="sap_belize"
data-sap-ui-libs="sap.m,sap.ui.table"></script>
Unfortunately, this approach means load cascading 4 scripts on startup:
sap-ui-core.js
sap/ui/core/library.js (why ?)
sap/m/library.js
sap/ui/table/library.js
Is there way to bundle this four libraries into one script file?
Unfortunately, this approach means load cascading multiple scripts on startup:
The cascading behavior is mostly due to missing an option that tells the framework to load UI5-libraries and other modules asynchronously. In order to fix it, please add the following attribute too:
data-sap-ui-async="true" // available since 1.58.2 --> Replaces preload="async" *
data-sap-ui-preload="async" // for 1.58.1 and below
* Prerequisite: Is Your Application Ready for Asynchronous Loading?
Is there way to bundle these four libraries into one script file?
Yes; with a self-contained build (e.g. ui5 build self-contained --all ), you can reduce the size of your application as well as number of requests by bundling the required modules into a single file sap-ui-custom.js
In the above screenshot, for example, sap-ui-custom.js contains only the required modules from sap.ui.core-, sap.m-, sap.ui.table-, and sap.ui.unified-library, in addition to application related resources such as the controllers, views, etc..
See openui5-sample-app and the UI5 tooling for official documentation.

merge large existing web app into Sailjs site

I'm trying to merge large existing web app into sails.js. so I moved the folders into assets and build a custom route , 'GET /': '/assets/client/launch.html' and get 404 when I point my browser to http://localhost:1337/ as the / is correctly redirected to http://localhost:1337/assets/client/launch.html which produces the 404.
Now the file exists in the folder assets/client (and in .tmp), so I am thinking the Sails router is getting in the way.
I would leave the client (70K lines of JS) that generates all the UI dynamically and sailjs server that provides authentication separate and enable CORS but my customer wants client packaged with server. This type of operation is simple in frameworks like ASP.NET MVC but am wondering if Sails is up to the task.
Well, If everything you tried did not work out. There might be another solution ,
First of all since you are talking about sails app I am assuming other bundle must be sails as well ,
So here is what you do-
Change the port for another app that you want to attach to this.
Second whenever you want to go to page on another app simply redirect the client to another port ie
in html or esp put a href tag with different port.
<a href="localhost:PORT/route_to_file">
</a>
I got it working by placing my app into assets where we need to launch from assets/client/index.html as there would be too many dependencies to change. As I said above could not just add a route as Sails must getting in the way. However as in Chapter 3.2.2 of Sails in Action I generated a static asset npm install sails-generate-static --save. then I redirected to assets/client/index.html. As an aside that book is great and would highly recommend it.

GWT lifecycle - Deferred binding at runtime.What happens

Can someone explain what happens after the java code is converted to Javascript by the GWT compiler?
how will the compiled javascript reach the client browser and when does this happen.
Well from your server, you serve a html page which should contain a tag that points to your compiled javascript.
Example of what the script tag would look like
<script type="text/javascript" language="javascript" src="http://example.com/js/project/project.nocache.js"></script>
The GWT compiler generates output files as described here.
At a very high level. There is a very tiny loader file (the .nocache.) which you should include in a script tag in your page. This file's only job is to determine the correct compiled application code files to request from the server. This load happens asynchronously after the nocache script has loaded.

In Gwt where the path of script(appName.gwt.js) which loads gwt app comes from?

I have started Gwt last week. And I was trying to create application without using sample app. So initially i have typed following line in html file(Application Name-loginAppGwt, package- LoginAppGwt)
<script type="text/javascript" language="javascript" src="LoginAppGwt/LoginAppGwt.nocache.js"></script>
but it was not loading the gwt module. When i changed it to
<script type="text/javascript" language="javascript" src="loginAppGwt/loginAppGwt.nocache.js"></script>
It was working fine.
But in one of the application which i have created using sample application of gwt, there was written(application name- testingApp, packagename- test)
<script type="text/javascript" language="javascript" src="testingapp/testingapp.nocache.js"></script>
So , my doubt is where this name comes from like in my application loginAppGwt was correct but in sample application testingapp was correct??
Thanks in advance.
Module name can be manipulated via <module rename-to="newname">. Then the path would be newname/newname.nocache.js
Check if your example had something similar in it's module descriptor.
Update:
Loading of JS scripts is affected by filesystem case-sensitivity because scripts are loaded from files. However, GWT-RPC is handled by servlets and is always case sensitive. This is important because, GWT-RPC urls are prepended with package name which seems to be derived from first part of script name in a host file (I just tested this).
So while the main script would be loaded on case-insensitive filesystems regardless of the script name case, the GWT RPC would only work if package names are equal.

zend headScript()->appendFile in IE (internet explorer)

Two lines of script
$this->headScript()->appendFile('/js/global.js', 'text/javascript');
$this->headScript()->appendFile('http://zendbase/js/global.js', 'text/javascript');
Firefox runs script by both ways(absolute, root relative)
Internet Explorer only run the Second method of append(absolute), which is with http. which is not a good way.
when I view source in browser I can see following line is added
<script type="text/javascript" src="/js/global.js"></script>
But browser is not reading. it is really beyond my understanding. It is strange. How can I make first line to work with document root path on all browsers including IE.
Is there any settings in view helper? or something else?
I can use $_Server variables to make it absolute dynamically but i don't want to use absolute path.
Any Idea. Thanks in advance :)
Relative paths for scripts will definitely work with IE - I have used it numerous times... What is the hostname you are using (e.g. www.example.com)? Your second line of code should not work, because you don't have a valid hostname - http://zendbase won't resolve to anything. Is zendbase a variable?
For relative static assets (images, JS, CSS, SWF, etc), you should always use the baseUrl helper, eg
$this->headScript()
->appendFile($this->baseUrl('/js/global.js'));
If you can see the correct <script> tag in source, then the problem is either the path is incorrect (see baseUrl helper above) or your JavaScript contains errors.
Finally I fixed the problem
I removed the baseUrl(); ?>" /> from layout.phtml
and added following line in application.ini
resources.frontController.baseUrl = ""