I am trying to find a way to reference a server side jss file from an external nsf application (in the same or another domino server).
I went to an xpage and then to its resources property. I selected to import a script library, then in the popup window i selected "server side" in the drop down and finally i tried to guess a url that could work.
I know it is not working like a client side javascript since csjs is just text parsed by the browser. But i dont understand why isn't it possible for an xpage to retrieve a jss from a url and then load it and parse it as if it was local...
Is it possible to load a jss from another nsf?
I don't think it's possible within an NSF. I think the problem is that you're comparing it to the process of Client-Side JavaScript Script Library rather than to server-side resources, and so thinking it's simpler than it technically would need to be. You can't load a Java class from another NSF and you can't (easily) load an XPage or Custom Control. Each NSF runs in its own JVM, so there may also be a requirement to start the external database's XPages runtime to load the SSJS script library. An SSJS script library can refer to other libraries, Java classes, managed beans, variables etc, and retrieving those will fail because the SSJS script library will be retrieved from database A as plain text (remember it's only code at runtime) and parsed within the context of database B. I think there are enough levels of complexity for it to be virtually unsupportable, especially when it can be done in a plugin since 8.5.2, which would be more self-contained.
I've tried accessing resources via backend HTTP sessions and you still need to authenticate to the server - it doesn't automatically pass login credentials or use the server access. So that's probably also a barrier that would (somehow) have to be overcome.
I believe Jesse Gallagher has managed to work out a way to load an XPage or Custom Control from another database via OpenNTF Domino API, but I don't think it's a recommended way. I doubt he's used it to try loading SSJS libraries. You may also encounter issues, because the code is in separate JVMs.
Basically, to access the same SSJS from multiple NSFs, it needs to be at a level of the server hierarchy above the NSF, so in an OSGi plugin. But if it's code for your own consumption, by that time, you'll most likely be writing Java rather than SSJS.
The best option in the meantime is to copy and paste or inherit from a template.