Applets and Ajax

Source: Internet
Author: User
Tags define local xslt

Applet definition

An applet is a Java program component that runs in a Web client environment.

Working principle

The applet is embedded in the Web page as code, labeled <applet></applet> labeled, and when the Java-enabled web browser encounters this pair of tags, it downloads the appropriate application code and executes the applet on the local computer.

Function Advantage

Applets can improve the interactivity and dynamic execution ability of Web pages

Development steps

(1) Editing the Java source file for the applet
(2) Compiling applets
(3) Creating an HTML file
(4) Accessing HTML pages, executing applets

Life cycle

The four methods in the Applet class provide a framework for users to develop applets on this framework
Init: The purpose of this method is to provide any initialization required for the applet program. This method is called after the param tag inside the applet tag is processed.
Start: This method is called automatically after the browser calls the Init method. This method is called whenever a user returns from another page to a page that contains an applet.
Stop: This method is called automatically when the user removes from the page that contains the applet. Therefore, you can call this method repeatedly in the same applet.
Destroy: This method is called only when the browser shuts down gracefully.
Paint: This method is called immediately after the start () method, or when the applet needs to be redrawn in the browser. The Paint method actually inherits from the java.awt

Security restrictions

1. Do not allow applets to access the local file system
2.Applet cannot perform any programs on the local computer
3. The applet is not allowed to attempt to open the socket of any system other than the server providing the applet
4. Do not allow applets to access local system-related information such as user name, e-mail address, etc.
5. For applets, some standard system properties in the Java environment are read-only
6.Applet cannot create or load the network connection of the applet machine
7.Applet cannot act as a network server, listening to or receiving connection requests from remote systems
8. Do not allow applets to load dynamic libraries or define local method calls
9.Applet cannot manipulate any thread that is not in its own thread group
10.Applet cannot shut down the JVM

The difference between a standalone Java application and a applets program:

(1) The Applet class in Java inherits the Java.applet.Applet class
(2) The applet class does not have a main () defined, so an applet program does not call the main () method
(3) Applets are designed to be embedded in an HTML page
(4) When the user browses the HTML page containing the applet, the applet's code is downloaded to the user's machine
(5) To view an applet requires JVM,JVM can be a plugin for a Web browser, or a standalone runtime environment
(6) The JVM on the user's machine creates an instance of an applet class and invokes various methods in the applet life cycle process
(7) Applets have strict security rules enforced by web browsers, and the security mechanisms of applets are known as sandbox security
(8) Other classes required by the applet can be downloaded in the form of a Java archive (JAR) file

Reference Source:Https://baike.baidu.com/item/Applet
Http://www.runoob.com/java/java-applet-basics.html

Ajax definitions

Ajax is asynchronous JavaScript and XML (asynchronous JavaScript and XML technology), which refers to a set of multi-technology browser-side web page development technology.
Similar to DHTML or Lamp,ajax does not refer to a single technique, but rather organically utilizes a range of related technologies. Although its name contains XML, the data format can actually be replaced by JSON, further reducing the amount of data to form so-called Ajaj.

Form defects

A traditional Web application allows the user to fill out forms (form). When a form is submitted, a request is sent to the Web server, the server receives and processes the incoming form, and then sends back a new page.
While most of the HTML code in the front and back two pages is often the same, the response time of the application depends on the response time of the server, since each application communication needs to send a request to the server. Causes the user interface to respond much more slowly than the native application.

Ajax advantages

Ajax applications can send and retrieve only the necessary data to the server, and the client uses JavaScript to handle the response from the server, because the amount of data exchanged between the server and the browser is reduced and the server responds faster. At the same time, a lot of processing can be done on the client machine making the request, so the load on the Web server is also reduced.
The biggest advantage of using AJAX is maintaining the data without updating the entire page. This allows Web applications to respond more quickly to user actions and avoid sending information that is not changed on the network.

Application

(1) using XHTML+CSS to express information
(2) using JavaScript to manipulate the DOM (Document Object Model) to run dynamic effects
(3) Manipulating data using XML and XSLT
(4) Asynchronous data exchange with a Web server using XMLHttpRequest or a new fetch API
  Note: Ajax is distinguished from RIA technologies such as Flash, Silverlight, and Java applets

Questions about Fallback

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, and the user usually wants to click the Back button to cancel their previous operation, but in an AJAX application it is not possible to do so.

Solution Solutions

The method before HTML5 is to reproduce the 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).

Workaround for unable to add status to Favorites or bookmarks

One way before HTML5 is to keep track of the URL fragment identifier (often called an anchor point, which is the part behind # in the URL) to allow 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.) )
HTML5 can then directly manipulate the browsing history and store the state of the page as a string, and the state will be hidden when the page is added to a Web collection or bookmark.
Both of these methods can also resolve problems that cannot be backed up.

Compatibility

AJAX-supported browsers include Internet Explorer, Chrome, Firefox, Opera, Konqueror, and Mac OS Safari. However, Opera does not support XSL format objects, nor does it support XSLT.

Reference Source:Https://zh.wikipedia.org/wiki/AJAX

Applets and Ajax

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.