Home  >  Article  >  Java  >  What is the difference between Applet and Servlet in Java

What is the difference between Applet and Servlet in Java

青灯夜游
青灯夜游Original
2018-12-20 18:05:076068browse

In Java, the main difference between Applet and servlet is: applet is an application that is executed on the client computer

Applet and servlet are small Java programs or applications; but there is a difference between them There are many differences. This article will introduce to you the difference between Applet and servlet. I hope it will be helpful to you.

What is the difference between Applet and Servlet in Java

What is Java Applet?

Applet is a dynamic Java program that can be embedded in a web page. It runs in a web browser and works on the client side. Applets are embedded in HTML pages using APPLET or OBJECT tags and are hosted on a web server.

What is Java servlet?

Servlet is a small Java program executed on the server side that can be used to process and answer client requests and implement the servlet interface; helps to maintain and support enhanced Web with minimal overhead Server functions.

The difference between Applet and servlet

1. The difference between operating environment

Applet is When executed on the client, the resources of the client computer will be utilized; while Servlet is executed on the server and utilizes the resources of the server.

2. The difference between the java package used and the import

The packages available in Applet are: import java.applet.*, and import java.awt.* . The packages available in Servlet are: import javax.servlet.*, and import java.servlet.http.*.

3. Different methods used in the life cycle

Applet’s life cycle methods are: init(), stop(), paint(), start(), destroy().

What is the difference between Applet and Servlet in Java

The life cycle methods of Servlet are: init(), service() and destroy().

4. Differences in user interface classes

Applet uses user interface classes such as AWT and Swing to create user interfaces. The servlet does not need to create any user interface, so there is no need to use any user interface class.

5. The difference in bandwidth

Applet uses more network bandwidth when executed on the client computer; while Servlet is executed on the server, so it requires less bandwidth.

6. Differences in execution

To execute the applet on the client computer, a Java-compatible web browser is required. However, servlets require a Java-enabled web server to handle client requests and responses.

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

The above is the detailed content of What is the difference between Applet and Servlet in Java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn