Subj : Question about Rhino contexts To : netscape.public.mozilla.jseng From : Jon Brisbin Date : Tue Sep 06 2005 02:21 pm I seem to be having problems getting the context in my executions of JavaScript. Before I switched to straight Rhino (i.e. cut out BSF from the equation) I noticed that my two different kinds of JavaScript don't talk to each other now. Here's what I mean: My web application framework looks at the DOM controlling it's execution via a Jelly script execution. I have a Jelly tag that handles the JavaScript scripting at this stage. Once that XML file is read, it is interrogated for the child elements, those are retrieved, and each is executed in order. When I was using BSF, I could pass the BSFManager into each of these scripting elements and anything declared in a JavaScript in one part of the application would be visible to another part of the application at a different point in the processing cycle. I'm pretty sure that's because the Rhino JavaScript engine in BSF just does a Context.enter(). When I'm not debugging, I use Context.enter(), but when I am debugging I have to do it differently because I'm using a global Context. Obviously, I can't use a global context in a multi-threaded web application, so I have to restrict myself to thread-based or processing-based techniques. So far, I've tried storing the Scriptable scope object that I use in a HashMap that gets passed between Jelly and my framework. I've also tried using Context.put(/get)ThreadLocal() and using a generic, global scope. I can't seem to figure out, even when I'm using Context.enter(), that my objects defined (like function definitions I want available to everyone who will executing during this run) in Jelly-based JavaScript processing don't get communicated to the next execution of JavaScript (where I'm also using Context.enter()). Since this is a web application, everything is getting executed in a single thread, so there should be no problems there. Jelly scripts are compiled and cached, but executed on every request, so I don't think things are getting set in Jelly and then not being available later because they are being accessed from a different thread than the one that created them. I could be wrong on that one, though... Any ideas? Thanks! Jon Brisbin NPC International, Inc. .