In today's multi-layered web application design, we can use both Java Applet and Servlet. The Applet provides a convenient mechanism for building a powerful dynamic interface. Servlet provides an efficient means for web servers or other application servers to process requests. Sun's application model describes the best specification for developing enterprise-level Java applications on the Java 2 platform. A recommended specification is to use the servlets and other components supported by Enterprise ans on the frontend using applets, HTML, and JSP.
The key to this architecture is the communication between the client Applet and the server assumervlet. However, because the Applet is restricted by the browser security mode, it is not as easy to access data and information in an Applet. In this article, we will explain the limitations faced by developers in the Applet-Servlet structure, and discuss several different communication policies that can transfer data between the Applet and Servlet. If you are familiar with the Applet and Servlet, this will certainly help you read this article. If you are not so familiar with it, it doesn't matter. We will briefly introduce them.
Introduction to Applet and Servlet
Java Applets is actually a Java program running on the web page. It is a java class inherited from Java. Applet. Applet. It is embedded into HTML pages through reference, just like an image. The combination of Applet and HTML allows you to build a more powerful dynamic interface. For some applets that only use to scroll the body and play the animation, we can use it in an enterprise-level application to display and process data from resources on the server. For example, an Applet can be used to browse and modify records in the database or control other applications running on the server.
In addition to its own class files, Java Applet can also use other classes, whether they exist independently or are packaged into a JAR file. The Applet and its class files are distributed through standard HTTP requests, so the Applet can be sent across the firewall of the platform where web page data is located. Unless it involves maintaining the integrity of the application, the Applet will automatically refresh each time the user re-accesses the web host and will be retained on the client for a period of time.
Thanks to the platform independence of the Java operating system, the Applet can run on any browser with the Java Virtual Machine JVM. Sun's Java Plug-in can even use the latest JVM version to compile pages without worrying about restrictions on the JVM version on your browser.
Because the Applet is an extension of the Java platform, you can reuse existing Java components when creating a web application interface with the Applet. As we can see in the following example, you can use complex Java objects in your Applet components to develop the work originally completed by the server application. In fact, you can write such Java code, which can be executed on the Applet or in the application.
Applet has all the functions of traditional Java applications, including using Sun's JFC/Swing components. Applets can also be used to create images and user interfaces in applications, although some auxiliary windows are marked as "Warning, Java Applet Window "). However, no matter how similar they are, there are still some key differences between applications and applets. For example, we have to consider that our Applet is restricted by the security mode.
- Servlet 2.5 termination response
- Wizard for creating Servlet Filters
- User cache Servlet
- Extract Servlet and JSP page content using the filter
- Servlet Context and Config