Java EE Fifth blog----Applets & Ajax

Source: Internet
Author: User
Tags define local

an Applet
Applets are small applications written in the Java programming language that can be included in the HTML ( Standard Universal Markup Language one of the applications)page, the same way you would include an image in a page. The HTML file code of the Web page containing the applet has a pair of tags such as <applet> and </applet>, when a Java-enabled web browser encounters this pair of tags, The appropriate applet code is downloaded and executed on the local computer. 1Working principleJava applets can greatly improve the interactivity and dynamic execution capabilities of Web pages. Pages that contain applets are called java-powered pages, which can be referred to as Java-supported web pages. WhenappletsWhen a user accesses such a Web page, the applet is downloaded to the user's computer for execution, but only if the user is using a Java-enabled web browser. Because the applet is executed on the user's computer, its execution speed is not limited by the network bandwidth or modem access speed, the user can better appreciate the multimedia effect produced by the applet on the webpage. In the Java applet, it can realize the functions of drawing, font and color control, animation and sound inserting, human-computer interaction and network communication. The applet also provides a window environment development tool called the Abstract Window Toolbox (TOOLKIT,&NBSP;AWT). AWT uses the GUI elements of the user's computer to create a standard graphical user interface, such as Windows, buttons, scroll bars, and so on. At present, there are many examples of applets on the network to vividly show these functions, readers can go to the corresponding pages to see their effects. The implementation of the applet  small application relies primarily on the applet class in the Java.applet package. Unlike a typical application, an applet application must be embedded in an HTML page to be interpreted and executed, while an applet can get parameters from a Web page and interact with the Web page. An applet is a Java applet that is run by a Java-enabled web browser by using the applet's HTML file. It can also be run through the appletviewer of Java development tools. The applet program cannot be separated from the HTML file that uses it. The information about the applet in this HTML file should contain at least the following three points: 1) The bytecode file name (the compiled Java file, with a. class suffix) 2) The address of the bytecode files 3) The way the applet is displayed on the Web page. An HTML file that increases the content of an applet simply makes the page more animated, such as adding sounds, animations, and other appealing features that do not alter the HTML file's irrelevant elements. &NBSP;2 security restrictions in order to prevent such problems, in the default case, most browsers in the applet security is subject to a number of restrictions, almost no system to do any "read" or "write" Operation: 1. Applets are not allowed to access local file system 2. Applets cannot perform any program 3 on the local computer. Applets are not allowed to attempt to open the Socket4 of any system other than the server that provides the applet. Applets are not allowed to access information about the local system, such as user names, e-mail addresses, etc. 5. For applets, some standard system properties in the Java environment are read-only 6. Applets cannot create or load appleT's machine's network connection 7. Applets cannot act as a network server, listening to or receiving connection requests from remote systems 8. Applets are not allowed to load dynamic libraries or to define local method call 9. Applets cannot manipulate any thread that is not in their own thread group 10. Applets cannot shut down the JVM.  3 Development Steps Applet program Development main steps are as follows: 1) Choose Edit or Windows Notepad as editor to build Java applet source program. 2) Convert the applet's source program to a bytecode file. 3) Compile the HTML file using class. Put the necessary <OBJECT> statements inside the HTML file.  

Second, Ajax

1.

Basic Introduction: Ajax derives from describing transformations from web-based applications to data-based applications. In data-based applications, data such as user needs, such as contact lists, can be obtained from the server independent of the actual Web page and can be dynamically written to the Web page, rendering the slow Web application experience like a desktop application.

The core of Ajax is the JavaScript object XMLHttpRequest. This object was first introduced in Internet Explorer 5, which is a technique that supports asynchronous requests. In short, XMLHttpRequest allows you to use JavaScript to make requests to the server and handle the response without blocking the user.

Ajax does not require a server, it can be a Java EE application. NET applications and other types of application services. With Ajax, you can write JavaScript code to improve HTML and create a rich interactive user experience.

2. Development mode:

Many important technologies and Ajax development patterns can be obtained from existing knowledge. For example, in an app that sends a request to the server, it must contain the order of requests, priority, timeout response, error handling, and callbacks, many of which are already included in the Web service, just like today's SOA. Ajax developers have a complete knowledge of the system architecture. At the same time, as technology matures there are many areas that need to be improved, especially the ease of use of UI parts.

Ajax development differs greatly from the traditional CS development. These differences introduce new programming problems, the biggest problem is ease of use. Because Ajax relies on browser-based JavaScript and XML, browser compatibility and support standards have become as important as JavaScript's runtime performance. Most of these problems come from a combination of browsers, servers, and technologies, so you must understand how best to use these technologies.

Ajax presents a new way to develop a variety of technologies and a highly-coupled customer-service environment. Ajax developers must understand the traditional MVC architecture, which limits the boundaries between application hierarchies. At the same time, developers need to consider the external of the CS environment and use AJAX techniques to re-stereotype MVC boundaries. Most importantly, AJAX developers must disallow Web applications as a collection of pages and need to consider them as a single page. Once the scope between the UI design and the service architecture is strictly differentiated, developers need to update and change the technology collection.

3: Advantages and Disadvantages:

Advantages:

Traditional web apps allow users to fill out forms (form) and send a request to the Web server when the form is submitted. The server receives and processes the form, and then returns a new page. This approach wastes a lot of bandwidth because most of the HTML code in the last two pages is often the same. Because each application interaction requires a request to the server, the response time of the application depends on the response time of the server. This causes the user interface to respond much more slowly than the local application.

Unlike this, an AJAX application can send and retrieve only the necessary data to the server, using SOAP or some other XML-based Web service interface, and using JavaScript on the client to process the response from the server. As a result, the amount of data exchanged between the server and the browser is reduced so that we can see more responsive applications. At the same time, a lot of processing can be done on the client machine making the request, so the processing time of the Web server is also reduced.

The biggest advantage of using AJAX is the ability to maintain data without updating the entire page. This allows the Web application to respond more quickly to user actions and avoids sending information that has not changed on the network.

Ajax does not require any browser plugins, but requires the user to allow JavaScript to be executed on the browser. Like the DHTML application, AJAX applications have to undergo rigorous testing on many different browsers and platforms. With the maturation of Ajax, a number of libraries that simplify the use of Ajax have been introduced. Similarly, there is another assistive programming technique that provides alternative functionality for users who do not support JavaScript.

Disadvantages:

The main criticism of applying Ajax is that it can disrupt the normal behavior of browser back buttons. In the case of dynamically updating the page, the user cannot go back to the previous page state because the browser can only record static pages in the history. The difference between a fully read page and a page that has been dynamically modified is very subtle; users often want to click the Back button to cancel their previous operation, but in an AJAX application it is not possible to do so. But developers have come up with ways to solve this problem, most of which is to reproduce changes on the page by creating or using a hidden iframe when the user clicks the Back button to access the history. (for example, when a user clicks back in Google Maps, it searches in a hidden iframe and then reflects the search results on an AJAX element to restore the application state to its current state.) )

A related view is that using dynamic page updates makes it difficult for users to save a particular state to a collection. The solution for this problem has also occurred, with most of the URL fragment identifiers (often referred to as anchors, which are the parts of the # URL) to keep track of, allowing the user to return to the specified application state. (many browsers allow JavaScript to dynamically update the anchor point, which allows an AJAX application to update the anchor point while updating the display.) These solutions also address many of the arguments that do not support back buttons.

With Ajax development, network latency-that is, the interval between a user sending a request to a server to make a response-requires careful consideration. Not giving users a clear response, without proper pre-reading data, or improper handling of XMLHttpRequest, will make users feel delayed, which is not what users want to see, but they do not understand. A common solution is to use a visual component to tell the user that the system is in the background and is reading data and content.

Some handheld devices (such as mobile phones, PDAs, etc.) are not yet well-supported Ajax;

JavaScript ajax engine, JavaScript compatibility and debug is a headache;

Ajax non-refresh overload, because the page changes do not refresh the overload so obvious, so easy to bring trouble to users-users are not very clear whether the current data is new or has been updated, the existing solution is: in the relevant location hints, data Update area design is more obvious, the data updated to the user prompt;

Java EE Fifth blog----Applets & Ajax

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.