A Java applet is a small application written in Java and embedded in a web page. It runs in the context of the web browser, and is typically used to provide interactive features to a web page, such as a game, calculator, or other interactive content.
A Java servlet is a server-side program written in Java and run in the context of a web server. It is typically used to generate dynamic web content, such as web pages or web services, based on user input.
For example, an applet might be used to provide a calculator on a web page, while a servlet might be used to generate a web page containing the results of a user’s search query.