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