Javascript to server side java using blazeds

Our current project involves connecting pure ActionScript 3 (no flex) to server side Java through BlazeDS.  When one of our users closes their browser window, we want the server side Java to perform various actions based on that user's status at the time they close the client.  

At the moment, we are looking to use JavaScript to send a message to the server when the window is closed.  Currently we have a sessionId for each user, so we can track them while they are in the program.  This is assigned by the server upon connection.  Our plan is to pass this session id from the server code (Java) to the client (AS3) to JavaScript upon assignment.  When the JavaScript code remotely calls one of our server functions (exit), which resides in a file called Admin, we will pass the session id as a parameter so the server knows which client has been closed.  Thus the server call will theoretically look something like this:

admin.exit(sessionID);

In our AS3 code, we are using remote objects to call functions on the server side.  I am unfamiliar with JavaScript, so would the JS code access the server-side Java in the same way as our ActionScript code, or is there maybe a better way to acheive our goal?
anotherfnAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
There is a better way and there is NO way to call anything by JavaScript from browser.

All you can do is to post HTTP requests to server side, that's all.

That is called: AJAX

Questions?

And for your sessionid is that you can place it in a form field, in a query URL string parameter or in a JavaScript variable that is created together with the html page.
Then JavaScript functions can use that sessionid to pass together with the AJAX calls.
For your purpose for clossing the page is the event onBeforeUnload the best choice.
But the problem is that onBeforeUnload is called every time when the page is reloaded so that is the standard problem that in HTTP you do not realy have something like sessions.

0
dgofmanCommented:
Add to your HTML body these two events and pass sessionID to Java servlet when user closing a browse

<body onbeforeunload="ConfirmClose()" onunload="HandleOnClose()">
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.