Page 1 of 1

Can I get JSM's port number like "document.location.host"

Posted: 25 Jul 2017, 20:31
by Fairdinkum
Hello,

I really need to know how to get the port number of JSM server which a session runs in order that making it easier to manage several JSM servers.

For example:
I use the script shown below.
--------------------------------------------------------------------
var ip = document.location.host.split(":")[0];

var id = FIELDS("G1001").getValue().trim();
if ( id === "" || id === null ){
alert("Enter the Product Code Please.");
}else{
var config =
{
serverUrl: "http://" + ip + ":5563/service/longreach.jsp",
credential: {user:"lansa", password:"lansa"}
};
LONGRANGE.FileTransfer.setDefaultConfig(config);
.......
--------------------------------------------------------------------

In this case, the port number "5563" in the above code has to be changed whenever it is changed in httpd.xml.

If the port number in the code becomes a variable, it would be much better.

Does anyone know that?

Thanks for your help.

Best Regards,
Hidekazu Tanaka

Re: Can I get JSM's port number like "document.location.host"

Posted: 25 Jul 2017, 20:37
by Fairdinkum
Finally, I was able to get the JSM port number using the following code:
--------------------------------------------------------
$(function() {
$.ajax({
type:'GET',
url:'/jsm/axinfo.json',
dataType:'json',
async: false,
success: function(res){
console.log(JSON.stringify(res));
alert( "SFM Port=" + res.sfm.port);
},
error:function(){console.log("failed...");}
});
});
--------------------------------------------------------

Thank you so much Alick and Frank :D