First knowledge of Servlets and JSPs

Source: Internet
Author: User

First, IntroductionServletand theJSP

Sun first launched the Servlet specification, it is a small Java programs, All is by Java writes and generates HTML , extends the functionality of the Web server , is located in Web Server -side inside the server. Java application.

later,Sun introduced a mosaic of ASP-like JSP, which consists of HTML code and embedded Java code. the server processes the Java code after the page is requested by the client , and then returns the resulting HTML page to the client browser .

Second,Servletand theJSPthe Relationship

Serlet is an early imperfect product, write Businesslayer very well, write presentation layer is very smelly (it output HTML statements are also used in the old CGI way, is a sentence output, it is very inconvenient to write and modify HTML , and two layers mixed.


so later Sun launched a similar to ASP's mosaic-type JSP ,JSP is The extension of servlet technology is essentially a simple way for servlets. The JSP is compiled with a "class servlet". The main difference between Servlets and JSPs is that the application logic of the servlet is in the Java file and is completely detached from the HTML in the presentation layer. The case for JSP is that Java and HTML can be combined into a file with a. jsp extension. JSP focus on the View ( jsp tag mosaic into the HTML statement, greatly simplifies and facilitates the design and modification of the Web page ), the servlet is mainly used for control logic.

Third,Netand theJavain the development ofMVC

according to Sun's own recommendation, JSP should only store the Presentationlayer related to the east, that is, only the output of the HTML page part. All data calculation, data analysis, database connection processing, all belong to Businesslayer, should be placed in Java beans. Java BEANS is called through JSP to achieve two-tier integration.

At this point, we have to mention the mainstream MVC model,

so-called The MVC model is a method of separating data, logic processing and user interface.

M (model, Models ): For data processing, logic processing.

V (View ): Used to display the user interface.

C (Controller, Controllers ): Control the logical direction and screen according to the client's request.

        speaking of which, I think of what we did before .Netproject, it's also usedMVCmodel, when it was the first time to contactMVC, and felt that one of theViewlayer is. aspxthe page,Controlleris a. ashxThe general processing procedure, this time to combine to doJavaproject, draw out such a picture, many details especiallyNetof theMVCThe strength may not show out, but generally can also give us some guidance on the macro, I hope you have more valuable advice!

MVC Model

ASP Development

MVC of the NET Development

MVC of the JAVA Development

M (Model)

, C1

. CS

. Java ( JavaBeans )

V (View)

. aspx

. cshtml

. JSP ( JSP )

C (Controller)

. ashx

Controller.cs

Controller. Java ( Servlet )



First knowledge of Servlets and JSPs

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.