In the past few years, Java platform technology has achieved some amazing progress. However, this technology is completely different in certain wide applications and its original design goals. Java platform technology initially wants to run Applet and Application through the client to add interactivity to web pages. The most common use of this technology is now based on the server-based J2EE system. In order to let the Java platform play its biggest potential in the client, people have developed many new technologies. Since the enterprise system is gradually replaced by the Internet app, it is necessary to master these new technologies. In this article, you can see how to use new and old technologies to achieve this. What is the problem in applet encounters? When the Java platform is issued, a new method is predicted to enhance the Internet from a static simple web page to high-level hierarchical levels. The initial purpose of Java founders is to provide developers with some ways to create a small program that can run on any client machine. These programs are also capable of combining client processes with server data to provide customers with a high degree of interactive experience. However, in some places, Java is not achieved for many features that Java committed to the client. The possible causes of this unfortunate include the following: The company's firewall usually prevents the Java Applet. Many clients do not provide a fully compatible Java virtual machine. Security settings do not allow using Applet to perform a lot of useful rules. When browsing the page, download a full-user interface, often make many users look at the Java Applet. Many user interface functions (printing, file management, and other similar tasks) must be re-implemented for different systems and different platforms. This is also why many developers avoid using Java Applet. With the growth of e-commerce on the Internet, the processing capacity of end users has increased, and the demand for communication bandwidth is rapidly. Use Java technology in the client component to become a very temptable thing. However, we need to study a new method, which can use the client's procedures, but also don't have to encounter obstacles that are similar to using Java Applets and scroll when scrolling the news column. These issues can be reduced through the combination of new and old technologies, and even the old technologies for forgetting some "Internet Age" that are almost rapidly run. Why is people call JavaScript When using Java technology in the client, the most ignored is the combination between Java Applet and JavaScript. The JavaScript standard has long provided a method for calling the Applet class for the script, and the applet can also call the function of the script. This combination allows us to exert the biggest strengths of these two technologies. We develop and maintain the functionality required to handle the design of the user interface to web developers. In addition, this combination is used, and it is also possible to increase the traces of the user's interaction of the user to leave a few clients. The LiveConnect technology in the JavaScript standard (see the data section) allows you to use the script in the web page to call the applet method. As long as you simply create the required Java class, you can access the method of the JavaScript script to access this class. The com.netscape.jsObject class makes us access JavaScript function and object. This provides a way to call the JavaScript function in the Java code, and directly make web pages that have fairly interesting and important changes. With the link between JavaScript and Java Applets, those JavaScript or Java Applet cannot be executed separately, but the task that is capable of combining these two methods can be resolved. Moreover, the combination of these two is typically capable of reducing the time of the web page to the server, thereby reducing the user waiting time, server processing time, and session state maintenance overhead of the server.
Consider the following example: While the user fills the form, the background thread uses the Java Applet to find address or phone number information in the server database. When SSL is not suitable for use, PKI technology is used to encrypt the communication between the system. Use the DSA standard to provide a powerful confirmation feature for the message content and senders. Use the Java Applet to submit a schedule change to the server database and update the local schedule display on the client's background. There is no need to make updates to all agents and minimize the time required for this change to take effect. Combined with the Java Applet and JavaScript code, dynamically displayed, constantly update the contents of the browser document; this combination allows us to write a print routine for each of the client platforms you want, and you can print it out. Listing 1 describes how to use JSObject and LiveConnect to verify a phone number while transforming the number into standard format. Note that this is just an example code, so I will ignore a number of must-have calls in the server connection method to simplify this list. This example is a Java Applet function in JavaScript when the content of the phone number input box changes. So the Java Applet accesses the server, obtain the standard format string of this phone number, and returns the string to hide box (Hidden Field). Really achieve this task, you should use the background thread to implement server connection and phone number verification so that the verification process is transparent to the user. This example also uses another technique that makes client Java more interesting techniques: HTTP connection and combining with server code (especially servlet, and JSP web pages). What is the resource that is based on the server that must be stored on the server? This type of server-based resource includes address verification, transportation cost calculation, and credit card verification. Support data and processing of high security must be placed on the server, but most of the verification processing, data conversion, and cost calculation processes can be migrated to the client system. Several Java language features that support this idea include: Java language provides intrinsic support for HTTP connections over the HTTPurlConnection object. At the same time, the other parts of the Java.NET package uses communication between the server code and the client code to simply and effectively generate data or packaging data. Many client Java Applet codes are actually the same as those running on the server. Now we can assign multiple tasks to the server and client, thereby reducing server loads, and may even reduce network connections. How to assign these tasks will depend on the type of system and user groups, but almost all systems will benefit because of adding some client processing, for example: Applet class can transform data from a series of formats to a single XML string format. This makes the server more easily handled data. The Applet class can compress data, that is, the data compression of those will be uploaded to the server, and divide these data into smaller packets, thereby further improving the reliability. When the user fills in the checkout form, the Applet class can calculate the address and transportation costs (in a larger server database, such calculations often need to interact). This method can reduce the time required for the final settlement, while allowing users to see the correct transportation fees and corresponding taxes before submitting orders. In order to play the biggest advantage of this technology, it is necessary to send a request to the server that returns the specified data. Java servlets have this capability. Many developers are not fully aware of the servlet to respond to any of the data, not just HTML or XML.
By returning a series of continuous objects or a compressed packet, the servlet can perform tasks such as address confirmation or transportation costs, and tax calculations. At the same time, the client code for these calculations can mask the user waiting time through the running of the background thread. A servlet is displayed in Listing 2, which receives the GET request with ZIP code and returns the calculation result of the transport fee. Also, a number of very important actual code is omitted here for the purpose of clearing the list. Note I use the ObjectOutputStream object to write the entire target chart into the response to returned. The Content Type requires some suitable values while assigning the Content handler to the client. This method can return a Java object, which contains customer transportation, processing costs, and calculation results of payable tax. If this object is only communicating with the client lattime thread, the user will not realize that he has already communicated with the server. The above technique for saving time has been implemented for several times, and most of the world is applying in various systems. I have promised some new technologies in front of me, and now I'm specifically elaborate. The most interesting Java new technology on the client is a Weblet. IBM AlphaWorks DirectDom is a specific implementation of this technology (see the data part). DirectDom allows access to the entire browser DOM Tree from the Java code (November 13, 2000, the W3C is recommended for Dom Level 2). Weblet does not have a user interface, and you must complete its work by manipulating the activity DOM documentation in your browser. Many techniques that originally needed to be complex JavaScript code can be implemented by this method. It must be noted that although DirectDom is an attractive technology, it is still in the alpha phase, is imperfect, and the latest version of Internet Explorer or Mozilla (M18) is required to run. However, this technology is enough to make you predict how it will be exciting future. Some examples of possible implementations are as follows: Add Weblet on a settlement page full of graphics and visual stimuli. Then when the user handles the settlement table, it is not necessary to switch between the form and the webpage every step, and the data can be exchanged with the server and complete the settlement. When the settlement needs to be confirmed, the Weblet submits the entire package to the server, and the server can be processed in accordance with the usual settlement process. A web page that displays the property message. The Weblet tells the page blank to mark the response of printing or saving the request, thereby preventing data from being shared distinguishable. Users can request some reports to applications on the Internet. The summary information of the report will be delivered immediately, and Weblet uses the background thread to download the details of the report. When the user is interested in a summary of the strike, as long as the mouse click on this entry, the Weblet can immediately respond to the mouse action, and the details are displayed below this entry. These specific information is downloaded by the background thread after downloading of the summary page. But users will not notice this. Another longer example, clearer display how Weblet works. In Listing 3, this example can be seen in the HTML page and a list of clients, and the Java code of the Weblet class. Although it is not suitable for the production environment, it is still useful. This example downloads a long demonstration page that contains two forms and a Weblet tag. Weblet uses some introductory text to replace these forms or switch these two forms during the demo.