Remote scripting using a servlet

xiaoxiao2021-03-06  93

Remote scripting using a servlet

CONTENTS:

Client SideredMond Scripting Jsrs Architecturelet's See Some Codenow What? IssuesconclusionResourcesoSabout The Authorrate this Article

Subscriptions:

DW Newslettersdw Subscription (CDS and Downloads)

How to Give Web Applications Interactivity and Dynamism That You'd Expect from Desktop Apps

Erik Hatcher

(Erik@hatcher.net) President, EHATCHER SOLUTIONS, Inc.1 February 2001

The users of Web applications have suffered a dramatic shift in experiences from the world of desktop applications. Many Web applications do not at all mimic the usability, interactivity, and dynamic nature that is available in typical standalone or client-server desktop applications because of the CONSTRAINTS THAT HTML AND HTTP IMPOSE. Here, Erik Hatcher Explains How Remote Scripting Can Be Used to Enhance The Interactivity and Dynamic Nature of A Web Application Experience.

One of the major drawbacks to Web applications is that the user experience is typically inferior to that of desktop applications. Most current Web applications lack in interactivity because once the browser receives a response to its URL request it is on its own, failing to communicate back to the server until a hyperlink is clicked or a form is submitted Techniques such as using JavaScript and DHTML can be used to make the browser feel more like a desktop application;. fancier techniques like using Flash, ActiveX, and Java applets can also accomplish this end. But even with these newer techniques and technologies, the client is still mostly on its own after it receives the content from the Web server. The technique described in this article offers a solution that allows the browser and Web server to communicate behind the scenes Browser CAN Invoke Remote Java Servlet Methods That Enable The User Experience To Remble That of A Desktop Application, Such as Populating A Drop-Down box dynamically based on the selection of a related drop-down box (that is, category / subcategory), or polling the server for messages and refreshing the display dynamically with continuously updated content. Client sideThere are two popular ways of accomplishing remote method invocation from a Web browser: Microsoft remote scripting (MSRS) and Brent Ashley's JavaScript remote scripting (JSRS) The goal of both is the same:.. to invoke remote methods and return the results to the browser Both methods were originally designed to communicate with remote methods Defined in Microsoft's Active Server Pages. This Article Provides a Way for Both of these Methods to Communicate with a java servlet on the server side. let '

s get into the architecture details of each of these techniques Redmond scripting Microsoft's remote scripting is part of the Visual InterDev development environment It consists of three pieces:.. an invisible Java applet, client-side JavaScript, and server-side JavaScript running in Active Server Pages. The Java applet handles the communications with the server. The client-side JavaScript communicates with the applet. The server-side JavaScript deals with taking the requested parameters and dispatching them to the specified server-side method. The communications are simply HTTP GET requests and responses, with the details of the method call sent as query parameters to the server-side script. There is much more to be said about Microsoft's remote scripting architecture, but that is beyond the scope of this article (see Resources). Figure 1 Shows The Architecture of Microsoft Remote Scripting Using A Servlet on The Server-Side. Steps Involved in Invoking A Remote Method Using Microsoft REMOTE Scripting:

The browser executes a JavaScript call to RSExecute (this resides in an included JavaScript framework provided by Microsoft Visual InterDev). The remote scripting applet uses HTTP GET to access a special servlet URL on the server, complete with method name and parameters. The servlet returns its XML-like response and the applet receives it. The response is interpreted by the remote scripting JavaScript and returned to the calling code. A call object is returned, and the actual return value is the .return_value property if the method is returned successfully. figure 1. Microsoft Remote Scripting Architecture JSRS ArchitectureBrent Ashley's JavaScript remote scripting accomplishes the same goal using a nifty DHTML trick of injecting a hidden