The difference between a "javaweb note" servlet and a JSP

Source: Internet
Author: User

The "1" JSP is compiled into a servlet the first time it is run and resides in memory for invocation.

"2" JSP is a Web development technology, Servlet is a server-side application of small programs, when we visit a JSP page, the server will turn this JSP page into a servlet applet run results, feedback to the client browser.

The "3" servlet corresponds to a control layer to invoke the corresponding JavaBean processing data, and finally returns the result to the JSP.

"4" generally in multi-tier applications, JSP is mainly used as the presentation layer, and the servlet is used as the control layer, because too much code in the JSP is not conducive to maintenance, and leave this to the servlet to implement, and a large number of duplicate code written in JavaBean.

"5" The difference between the two is that the development interface is JSP directly can be written.

For example, write the table tag in the JSP: <table>[data]</table>;

The servlet needs to join: Out.println ("<table>[data]</table>").

The JSP file is compiled into a servlet file after it has been called by the application server. This means that the servlet file is actually displayed on the Web page. Tomcat the resulting servlet file after compiling the JSP file is placed under the work folder, and the HTML code in the JSP is out of the servlet, and the JSP code is placed in a different location depending on the label.

"6" In a standard MVC architecture, the servlet takes a user request as a controller and forwards it to the corresponding action handler, which is primarily used to generate dynamic pages as a view, and EJB implements your business code as a model.

Simply put: Use Servlets to control business processes and use JSP to generate dynamic Web pages.

The difference between a "javaweb note" servlet and a JSP

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.