Wednesday, November 09, 2005

AJAX on Mustang, but why?

I can't help the itch to respond to A. Sundararajan's post @ blogs.sun.com. He states that with the upcoming Mustang release, it will contain support for JavaScript. Yes, Mustang will have a new package called javax.script. The implementation to the scripting API is JavaScript-based and will be leveraging on the Rhino JS Engine. For history purposes, Rhino is an open-source implementation of a JavaScript engine written entirely in Java.

OK, the key elements to AJAX are:
  • XML, usually in form of JSON (JavaScript Object Notation)

  • Asynchronous mechanisms

  • JavaScript.


As A. Sundararajan says, AJAX is now enabled in Java, specifically on the consuming if the JSON messages and processing them through JavaScript.

"This implies you can transfer and read data from web/app server in JSON format and read the same in client (web browser or JavaWebStart) side easily -- all you have to do is to make reader from your (URL) input stream and eval it!"


But then again, when a Java program (GUI/Swing) communicates using XML as the data, it is still that Java program who will consume it. What do you need the JavaScript for? Java can parallel-task using threads, can operate on XML using JAX* and can definitely render more functional and interactive GUI through Swing. One thing that has not been considered when JavaScript was thought of to enable AJAX in Java is that AJAXified content uses CSS/P (a.k.a. Layers) to render the XML content back into user-understanble format. Java has Swing and I think "AJAX" through javax.script wil not do the trick.


You can find the original post and post comments here.