Here we will talk about JSP and Servlet, which do not involve struts, hibernate, spring, EJB, and other frameworks.
Speaking of JSP and Servlet, we all know that Java Web technology can be used to generate HTML pages and parsed by Java virtual machines. To put it simply, JSP is the HTML embedded with Java code, servlet is the Java Embedded with HTML code, or this is more vivid.
When should I use JSP? When should I use Servlet? It seems that there is no clear boundary. Comparatively, JSP display is more elegant, and Servlet logic is easier. By the way, JSP is compiled into a Servlet and then loaded and executed. That is to say, Servlet cannot implement functions without JSP.
Generally, the following division of labor should be reasonable: servlet captures requests, processes business logic, calls the bean component to save data, distributes the display, and JSP processes the display part.