Servlets are java code that produce HTML code. They run on the Web server. A servlet must be compiled into byte code before it can run.
Here are some Web application files that use a very simple servlet:
JSPs allow a Web developer to write mostly using HTML, but occasionally calling tags and java code to produce dynamic content. A JSP is automatically converted into a servlet for it to run.
Here are some Web application files that use a very simple JSP: