Applets and Servlets are both Java technologies, but they serve very different purposes:
Applets
What is an Applet?
A Java program that runs in a web browser.
Meant for client-side execution.
Requires a Java plugin in the browser (now deprecated and unsupported by most browsers).
Characteristics:
Feature
Description
Execution
Runs on the client machine (browser).
GUI Support
Yes (Swing or AWT).
Use Case
Old-school interactive web UIs.
Security
Runs in a sandbox (restricted).
Obsolete?
✅ Yes. No longer supported by browsers.
Example:
importjava.applet.Applet;importjava.awt.Graphics;publicclassHelloAppletextendsApplet{publicvoidpaint(Graphicsg){g.drawString("Hello from Applet!",20,20);}}
Servlets
What is a Servlet?
A Java class that runs on a server and handles HTTP requests and responses.
Used to build web applications (server-side logic).
Forms the foundation for Spring MVC, JSP, and Java EE web apps.
Characteristics:
Feature
Description
Execution
Runs on the server (inside servlet container like Tomcat).
importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;publicclassHelloServletextendsHttpServlet{protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{response.setContentType("text/html");PrintWriterout=response.getWriter();out.println("<h1>Hello from Servlet!</h1>");}}
Applet vs Servlet Comparison Table
Feature
Applet
Servlet
Runs On
Client (Browser)
Server (Web container)
Purpose
GUI applications in browsers
Handle web requests/responses
GUI Support
Yes (AWT/Swing)
No (Returns HTML or data)
HTML Interaction
Embedded in HTML pages
Processes requests from HTML forms
Browser Support
Deprecated
Widely supported
Security
Runs in restricted sandbox
Server-side security (authentication etc.)
Modern Usage
Obsolete
Still heavily used (Spring Boot, JSP)
Conclusion
Applets are outdated and no longer used.
Servlets are foundational for modern Java web development (including Spring Boot).
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Top comments (0)