I'm working on modernizing a fairly hefty application with a lot of existing script libraries which we want to leverage within the XPages environment. Here is a technique that works very well. First, create an in-memory document in SSJS. We can set any input values needed for the back end. Then we pass that document to a LS Agent which can work it's magic using the values set in SSJS and use the same document to return values back to the XPage. Here is how it works in detail:
Get expert Domino tips and techniques for Lotuscript, Java, Javascript, SSJS and XPages here. I have over 15 years of experience with Domino, Java, and XPages.