The difference between servlet and JSP

Source: Internet
Author: User

SOURCE Link: The difference between a servlet and a JSP

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.

The "4" servlet is primarily used for steering, turning requests to the appropriate JSP pages.

"5" JSP more is the page display, servlet is more processing business, that is, JSP is a page, servlet is the way to implement JSP.

The "6" servlet can implement all the functions of the JSP, but since the artist uses the servlet to make the interface very difficult, the JSP was later developed.

"7" JSP technology development Site two modes: JSP + javabean;jsp + Servlet + JavaBean (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, This is left to the servlet, and a lot of repeating code is written in JavaBean.

"8" 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>").

JSP files are compiled into servlet files after they have been called by the application server (for example: Tomcat, Resin, WebLogic, and WebSphere). 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.

Java code is embedded in the "9" JSP, and HTML code is embedded in the servlet.

"10" 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.

The difference between servlet and JSP (GO)

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.