diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js
index aa7c6d118e6161defc8a79549869411a135d452a..71775249221b3e442cd644e20a950f9b7f60acbd 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis.js
@@ -8,16 +8,16 @@ if(typeof $ == 'undefined'){
 	alert('Loading of openbis.js failed - jquery.js is missing');
 }
 
-function _openbisInternal(openbisUrl){
-	this.init(openbisUrl);
+function _openbisInternal(openbisUrlOrNull){
+	this.init(openbisUrlOrNull);
 }
 
-_openbisInternal.prototype.init = function(openbisUrl){
-	this.openbisUrl = openbisUrl;
-	this.generalInfoServiceUrl = openbisUrl + "/rmi-general-information-v1.json";
-	this.generalInfoChangingServiceUrl = openbisUrl + "/rmi-general-information-changing-v1.json";
-	this.queryServiceUrl = openbisUrl + "/rmi-query-v1.json";
-	this.webInfoServiceUrl = openbisUrl + "/rmi-web-information-v1.json"
+_openbisInternal.prototype.init = function(openbisUrlOrNull){
+	this.openbisUrl = this.normalizeOpenbisUrl(openbisUrlOrNull);
+	this.generalInfoServiceUrl = this.openbisUrl + "/rmi-general-information-v1.json";
+	this.generalInfoChangingServiceUrl = this.openbisUrl + "/rmi-general-information-changing-v1.json";
+	this.queryServiceUrl = this.openbisUrl + "/rmi-query-v1.json";
+	this.webInfoServiceUrl = this.openbisUrl + "/rmi-web-information-v1.json"
 }
 
 _openbisInternal.prototype.log = function(msg){
@@ -26,6 +26,18 @@ _openbisInternal.prototype.log = function(msg){
 	}
 }
 
+_openbisInternal.prototype.normalizeOpenbisUrl = function(openbisUrlOrNull){
+	var urlParts = null;
+	
+	if(openbisUrlOrNull){
+		parts = this.parseUri(openbisUrlOrNull);
+	}else{
+		parts = this.parseUri(window.location);
+	}
+	
+	return parts.protocol + "://" + parts.authority + "/openbis/openbis";
+}
+
 _openbisInternal.prototype.jsonRequestData = function(params) {
 	params["id"] = "1";
 	params["jsonrpc"] = "2.0";
@@ -58,7 +70,7 @@ _openbisInternal.prototype.ajaxRequestError = function(action){
 	return function(xhr, status, error){
 		openbisObj.log("Request failed: " + error);
 		action({
-			"error" : error
+			"error" : "Request failed: " + error
 		});
 	};
 }
@@ -90,6 +102,37 @@ _openbisInternal.prototype.eraseCookie = function(name) {
 	this.createCookie(name,"",-1);
 }
 
+// parseUri 1.2.2 (c) Steven Levithan <stevenlevithan.com> MIT License (see http://blog.stevenlevithan.com/archives/parseuri)
+
+_openbisInternal.prototype.parseUri = function(str) {
+	var options = {
+		strictMode: false,
+		key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
+		q:   {
+			name:   "queryKey",
+			parser: /(?:^|&)([^&=]*)=?([^&]*)/g
+		},
+		parser: {
+			strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+			loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
+		}
+	};
+	
+	var	o   = options,
+		m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
+		uri = {},
+		i   = 14;
+
+	while (i--) uri[o.key[i]] = m[i] || "";
+
+	uri[o.q.name] = {};
+	uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
+		if ($1) uri[o.q.name][$1] = $2;
+	});
+
+	return uri;
+}
+
 _openbisInternal.prototype.listDataStores = function(action){
 	this.ajaxRequest({
 		url: this.generalInfoServiceUrl,
@@ -212,8 +255,8 @@ _openbisInternal.prototype.getDataStoreApiUrlForDataSetCode = function(dataSetCo
  * 
  */
 
-function openbis(openbisUrl) {
-	this._internal = new _openbisInternal(openbisUrl);
+function openbis(openbisUrlOrNull) {
+	this._internal = new _openbisInternal(openbisUrlOrNull);
 }
 
 /**
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js-new/openbis-screening.js b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js-new/openbis-screening.js
index 1a145a1ecd22a521c99e5c3d40fe424dc5f9af7c..c7afccaa4f6dda5eda35880bcbc4126f257e37d7 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js-new/openbis-screening.js
+++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/public/resources/js-new/openbis-screening.js
@@ -10,15 +10,15 @@ if(typeof openbis == 'undefined' || typeof _openbisInternal == 'undefined'){
 
 var _openbisInternalGeneric = _openbisInternal;
 
-var _openbisInternal = function(openbisUrl){
-    this.init(openbisUrl);
+var _openbisInternal = function(openbisUrlOrNull){
+    this.init(openbisUrlOrNull);
 }
 
 $.extend(_openbisInternal.prototype, _openbisInternalGeneric.prototype);
 
-_openbisInternal.prototype.init = function(openbisUrl){
-    _openbisInternalGeneric.prototype.init.call(this, openbisUrl);
-    this.screeningUrl = openbisUrl + "/rmi-screening-api-v1.json"
+_openbisInternal.prototype.init = function(openbisUrlOrNull){
+    _openbisInternalGeneric.prototype.init.call(this, openbisUrlOrNull);
+    this.screeningUrl = this.openbisUrl + "/rmi-screening-api-v1.json"
 }
 
 _openbisInternal.prototype.getScreeningDataStoreApiUrlForDataStoreUrl = function(dataStoreUrl){
@@ -40,8 +40,8 @@ var _openbisGeneric = openbis;
  * 
  */
 
-var openbis = function(openbisUrl){
-	this._internal = new _openbisInternal(openbisUrl);
+var openbis = function(openbisUrlOrNull){
+	this._internal = new _openbisInternal(openbisUrlOrNull);
 }
 
 $.extend(openbis.prototype, _openbisGeneric.prototype);
diff --git a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js
index 9660208bc403461ea4a9c754766cadb00100f352..f1a5dff080df568230562defff2f9bdad487dcd2 100644
--- a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js
+++ b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/common-test/html/common-test.js
@@ -1,7 +1,7 @@
-var createFacade = function(action, timeoutOrNull){
+var createFacade = function(action, url, timeoutOrNull){
 	stop();
 	
-	var facade = new openbis('http://127.0.0.1:8888/openbis/openbis');
+	var facade = new openbis(url);
 	
 	facade.close = function(){
 		facade.logout(function(){
@@ -32,12 +32,14 @@ var createFacade = function(action, timeoutOrNull){
 	startWhenClosed();
 }
 
-var createFacadeAndLoginForUserAndPassword = function(user, password, action, timeoutOrNull){
+var createFacadeAndLoginForUserAndPassword = function(user, password, action, url, timeoutOrNull){
 	createFacade(function(facade){
-		facade.login(user, password, function(){
-			action(facade);
+		facade.login(user, password, function(response){
+			if(!response.error){
+				action(facade);
+			}
 		});
-	}, timeoutOrNull);
+	}, url, timeoutOrNull);
 }
 
 var createSearchCriteriaForCodes = function(codes){
diff --git a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-screening-test/html/openbis-screening-test.js b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-screening-test/html/openbis-screening-test.js
index d95fed165c351245f1d2d15887e8b91eeac496b9..88e480b930b90183c6669d8b9f963c5b071ffac9 100644
--- a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-screening-test/html/openbis-screening-test.js
+++ b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-screening-test/html/openbis-screening-test.js
@@ -3,8 +3,16 @@
  * with screening sprint server database version
  */
 
-var createFacadeAndLogin = function(action, timeoutOrNull){
-	createFacadeAndLoginForUserAndPassword('openbis_screening_test_js', 'password', action, timeoutOrNull);
+var testProtocol = "http";
+var testHost = "127.0.0.1";
+var testPort = "8888";
+var testUrl = testProtocol + "://" + testHost + ":" + testPort;
+
+var testUserId = "openbis_screening_test_js";
+var testUserPassword = "password";
+
+var createFacadeAndLogin = function(action, urlOrNull, timeoutOrNull){
+	createFacadeAndLoginForUserAndPassword(testUserId, testUserPassword, action, urlOrNull ? urlOrNull : testUrl, timeoutOrNull);
 }
 
 var createExperimentIdentfier = function(identifierString){
diff --git a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js
index ad14307676ed5b6700c6c322c442fbbee96b68fb..7031fe1034e8794bc19fd6867f8d8e23dda52dc0 100644
--- a/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js
+++ b/screening/sourceTest/core-plugins/JsTests/1/as/webapps/openbis-test/html/openbis-test.js
@@ -3,11 +3,16 @@
  * with screening sprint server database version
  */
 
+var testProtocol = "http";
+var testHost = "127.0.0.1";
+var testPort = "8888";
+var testUrl = testProtocol + "://" + testHost + ":" + testPort;
+
 var testUserId = "openbis_test_js";
 var testUserPassword = "password";
 
-var createFacadeAndLogin = function(action, timeoutOrNull){
-	createFacadeAndLoginForUserAndPassword(testUserId, testUserPassword, action, timeoutOrNull);
+var createFacadeAndLogin = function(action, urlOrNull, timeoutOrNull){
+	createFacadeAndLoginForUserAndPassword(testUserId, testUserPassword, action, urlOrNull ? urlOrNull : testUrl, timeoutOrNull);
 }
 
 var createMaterialIdentifier = function(identifierString){
@@ -174,6 +179,60 @@ var generateRandomString = function(){
 	return Math.random().toString();
 }
 
+test("new openbis()", function(){
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server without url");
+		facade.close();
+	});
+});
+
+test("new openbis(protocol, host, port)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort;
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
+
+test("new openbis(protocol, host, port, /openbis)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort + "/openbis";
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
+
+test("new openbis(protocol, host, port, /openbis/)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort + "/openbis/";
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
+
+test("new openbis(protocol, host, port, /openbis/openbis)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort + "/openbis/openbis";
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
+
+test("new openbis(protocol, host, port, /openbis/openbis/)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort + "/openbis/openbis/";
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
+
+test("new openbis(protocol, host, port, /someRandomPath/)", function(){
+	var url = testProtocol + "://" + testHost + ":" + testPort + "/someRandomPath/";
+	createFacadeAndLogin(function(facade){
+		ok(true, "Successfully connected to server with url: " + url);
+		facade.close();
+	}, url);
+});
 
 test("logout", function(){
 	createFacade(function(facade){
@@ -188,7 +247,7 @@ test("logout", function(){
 				facade.close();
 			});
 		});
-	});
+	}, testUrl);
 });
 
 test("login", function() {
@@ -202,7 +261,7 @@ test("login", function() {
 				facade.close();
 			});
 		});
-	});
+	}, testUrl);
 });
 
 test("cookies", function() {
@@ -217,7 +276,7 @@ test("cookies", function() {
 		facade.restoreSession();
 		equal(facade.getSession(), 'session-1', 'Session 1 restored')
 		facade.close();
-	});
+	}, testUrl);
 });
 
 test("listNamedRoleSets()", function(){