Develop rich Internet applications for WebSphere Application Server Community Edition

Source: Internet
Author: User
Tags html page http request tomcat websphere application server

This article supporting source code

Introduction

Ajax (Asynchronous JavaScript and XML) terminology is used to represent a set of technologies that support the creation of rich Internet applications (Rich Internet application). By using these technologies, you can create Web applications that are responsive and have a rich user interface similar to desktop applications. These technologies allow you to retrieve data asynchronously in the background without affecting the displayed page, and you can request only data without requesting an entire HTML page. This asynchronous background communication can be done using the XMLHttpRequest or equivalent object provided by the current browser.

The installation package for IBM WebSphere application Server Community Edition v2.1.x (hereinafter called Community Edition) provides a popular framework for developing and hosting AJAX-enabled applications. In this article, we'll learn how to configure and use three of these frameworks, namely:

Dojo Tool Kit

Directwebremoting (DWR)

Tomcat Comet support

We will also develop a simple Web application that uses these technologies to provide an improved user experience. To follow the instructions in this article, you need the WebSphere application Server Community Edition v2.1.x.

Dojo Tool Kit

Dojo is a set of open source DHTML tools written using JavaScript. Dojo solves some of the problems with JavaScript, including handling browser-specific behavior. These actions have been abstracted from the user level through Dojo tools.

In addition, a set of configurable widgets can be used to quickly develop browser-independent dynamic Web pages. The Dojo toolset consists of a set of JavaScript APIs contained in WebSphere application Server Community Edition v 2.1. You can access this toolset by root/dojo up and down. Dojo also provides an API for making asynchronous XMLHttpRequest calls to get data from the server without refreshing the page.

Directwebremoting (DWR)

DWR allows developers to expose server-side Java™ objects to clients through JavaScript proxies. It creates proxies for all exposed Java™ objects to invoke these objects from the client. Accordingly, DWR will call the corresponding Java method in the server and return the response to the caller script in JSON (JavaScript Object notation) format.

You can configure DWR to call the server synchronously or asynchronously in the background. Therefore, you can avoid page refreshes associated with the normal HTTP request-response pattern.

DWR also provides reverseajax, a mechanism for sending information asynchronously from the server to the browser. By doing this, the server can send responses to the client on a regular basis in the following ways:

Polling: Clients periodically poll the server.

Comet: When a client makes a request, the server retains the response handle, and the write content is saved in this handle. In this case, the client does not need to poll.

Merge: Multiple responses are grouped together and sent with the response of the next request made by the client.

Tomcat Comet Support

The Comet term was invented by Alex Russel of the Dojo Foundation, which describes the event-driven server push mechanism through the HTTP protocol. In normal HTTP communications, the client always initiates a data transfer by opening a connection to the server and sending a request. The server processes the request, sends a response on the same connection, and then closes the connection. Therefore, the connection has a relatively short life span. In Comet, the server keeps the connection open and continues to write data to the associated event as it occurs. Tomcat P provides this support through NIO and APR connectors. The BIO connector does not provide Comet support.

Creating a NIO Connector

By default, Community Edition does not provide preinstalled NIO connectors. Before running an application that uses the Comet protocol, we need to create a new NIO connector from the admin console and start it. We will first remove the BIO connector running on port 8080 and then create a new NIO connector to run on this port.

To create a NIO connector, follow these steps:

Start the Community Edition and open the https://localhost:8443/console/in the browser.

Enter the username system and enter the password manager. Click Login to open the Welcome page in the admin console.

In the left navigation Pane, click the Webserver link to open the Webserver Manager page, as shown in Figure 1:

Figure 1.WebServer Manager

Remove the connector named Tomcatwebconnector.

In the ADD New section, click the Tomcat NIO Connector link, and the screen shown in Figure 2 opens.

Figure 2. Add a new Tomcat NIO connector

Fill in the Tomcatnioconnector value in the UniqueName field and click Save to create and start the NIO connector. Your window display should be similar to Figure 3.

Figure 3. Tomcatnioconnector added to the network listener

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.