|A Java applet is a small application which is written in Java and delivered to users in the form of bytecode.||A servlet is a Java programming language class used to extend the capabilities of a server.|
|Applets are executed on client side.||Servlets are executed on server side.|
|Applets are used to provide interactive features to web applications that cannot be provided by HTML alone like capture mouse input etc.||Servlets are the Java counterpart to other dynamic Web content technologies such as PHP and ASP.NET.|
|Life cycle of Applets init(), stop(), paint(), start(), destroy().||Lifecycle of servlets are:- init( ), service( ), and destroy( ).|
|Packages available in Applets are :- import java.applet.*; and import java.awt.*.||Packages available in servlets are:- import javax.servlet.*; and import java.servlet.http.*;|
|Applets use user interface classes like AWT and Swing.||No User interface required.|
|Applets are more prone to risk as it is on the client machine.||Servlets are under the server security.|
|Applets utilize more network bandwidth as it executes on the client machine.||Servlets are executed on the servers and hence require less bandwidth.|
- Creating “hello world” Applet.
// A Hello World Applet
// Save file as HelloWorld.java
// HelloWorld class extends Applet
// Overriding paint() method
- Creating “hello world” Servlet.
// Import required java libraries
// Extend HttpServlet class
// Do required initialization
// Set response content type
// Actual logic goes here.
PrintWriter out = response.getWriter();
+ message +
// do nothing.
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- Web Browsers that support Java Applets and how to enable them
- HTML | DOM applets Collection
- Introduction to Java Servlets
- Attributes in Servlets | Java
- Java Servlets | Need of Filters
- Difference between node.js require and ES6 import and export
- Difference and similarities between HashSet, LinkedHashSet and TreeSet in Java
- Similarities and Difference between Java and C++
- Difference Between DOS and Windows
- Difference between Scanner and BufferReader Class in Java
- Difference between Abstract Class and Interface in Java
- Difference Between Apache Kafka and Apache Flume
- Difference between == and .equals() method in Java
- Difference between x++ and x=x+1 in Java
- Difference between super() and this() in java
- Difference between Simple and Compound Assignment in Java
- Difference between throw and throws in Java
- Difference between notify() and notifyAll() in Java
- Difference between ODBC and JDBC
- Difference between Traditional Collections and Concurrent Collections in java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.