Similarities and differences between Dwr and Ajax

Source: Internet
Author: User
Tags blank page

Similarities and differences between Dwr and Ajax
1. What is ajax?
1. It is a client technology that combines old technologies to produce a new application.
2. You can interact with any program developed by the server.
3. ajax is not a new language or technology, but a combination of xml, dom, js, css, and other technologies.
4. Asynchronous interaction.

2. ajax Execution Process
1. Send an Http request: it is sent through the XMLHttpRequest object. When generating the XMLHttpRequest object, you must differentiate the browser type (IE and non-IE)
2. Declare the callback function: Specify the javaScript function used to process the response when the server responds to your request.
3. Open the request: ("GET/POST", url, true/false );
4. Send the request: http_request.send (parm );
5. Accept the response: it is accepted by the callback function specified in step 2.
6. Process Response Data:
1) responseText: returned as a text string
2) responseXML: returned as an Xml file
From this point we can see that one of the biggest disadvantages of Ajax is That Ajax accepts all the responses of the "text type" and needs to be parsed, which consumes a lot of time and bandwidth,
When the response data is large, it will seriously affect the speed. Therefore, in this case, it is best not to use Ajax

3. Advantages and Disadvantages of ajax:
1. The biggest difference is that the page is refreshed and communicates with the server on the page, providing a good user experience.
2. Use asynchronous mode to communicate with the server, without interrupting user operations, so as to have a more rapid response capability.
3. You can pass on some of the previous server workload to the client and use the idle client capability to handle it.
4. Based on standardized and widely supported technologies, you do not need to download plug-ins or applets.

Disadvantage: 1. It may damage the normal behavior of the browser's back button. For example, users usually want to click the back button to cancel their previous operation, but they cannot do this in Ajax applications.
2. ajax is not suitable when a query returns a large amount of data (ajax is not suitable for transmitting a large amount of data)

4. Why does ajax appear?
Ajax is used to develop clients with complex B/S architectures.
Traditional B/S architecture software
1. synchronous interaction method: Request-wait-response type;
Disadvantage: 1. user operations will be interrupted.
2. If the network speed is slow, a blank page will appear, which is unfriendly to users.
3. Each response replaces all content on a page with all content on the entire browser.

5. Understand the applicable and inapplicable scenarios of AJAX.

Ajax application scenarios
1. Form-driven Interaction
2. Deep tree navigation
3. fast communication and response between users
4. Irrelevant scenarios such as voting and yes/no
5. Data Filtering and data manipulation scenarios
6. common text input prompts and Automatic completion scenarios

Ajax not applicable scenarios
1. Some simple forms
2. Search
3. basic navigation
4. Replace a large amount of text
5. Rendering operations

The core of AJAX is xmlHttpRequest, which is a technology that supports asynchronous requests. In short, XmlHttpRequest allows users to use JavaScript to request and process responses to the server without blocking users.


1. DWR (direct web remote) concept: it encapsulates ajax. ajax sends a request through js, is intercepted by the Servlet, and uses the Servlet to deal with the persistent layer, DWR encapsulates the Servlet layer so that js can directly call the method of the persistent layer.

2. Simple Configuration:


                    import java.util.List;         import com.lxit.BackControl;         import com.lxit.Student;              

<script type='text/javascript' src='dwr/interface/test.js'></script>     <script type='text/javascript' src='dwr/engine.js'></script>     <script type='text/javascript' src='dwr/util.js'></script> 

DWR contains two main parts:
1>. A Java program running on the server
2>. JavaScript running on the browser, which sends requests and dynamically updates webpages

What is the relationship between Ajax and Dwr?
1. Ajax is a Web development technology used to create interactive Web applications, implement partial refresh, and exchange data with Web servers using client scripts.

2. Dwr is a framework based on Ajax. Therefore, Dwr has the Ajax function and can directly call the java method in javascript,
To achieve partial refresh, we can also say that Dwr is a Java encapsulation of Ajax.

DWR 3.0 push technology; the following versions are pull technology.
DWR reverse asynchronous Technology (push-pull technology, the biggest feature after DWR2.0)
1. References
1.1: The biggest difference between B/S (Browser/Server) structure and C/S (Client/Server) structure is:
A specific client needs to be deployed in the C/S structure. After the client establishes a connection with the server, the server can actively communicate with the client;
In B/S structure, only the browser sends a request to the server can obtain the server response.
1.2: The DWR push technology draws on the C/S idea and implements active communication between the server and the client in the B/S structure. The disadvantage of the push technology is:
When there are too many clients, the server load will be very high.
Pull Technology is a common B/S mode. Only when a request is sent can a response be obtained.
2. Three Modes for implementing DWR push technology
2.1: Polling is actually a Pull Technology
The client sends a request to the server at a certain period of time to check whether there is any data update on the server. If there is any update, the client requests data from the server.
2.2: Comet
After the client sends a request to the server, the server sends the data to the client through response, but does not close this response,
Instead, keep using response to get the latest number.
Send data to the client browser until the client browser is closed
2.3: Piggback (return)
The server queues the latest data, waits for the next request from the client, and sends the updated data to the client after receiving the request.

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: 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.