Comparison of architectural mode in the web development framework (2)

zhaozj2021-02-16  50

Server Page (page content and logic)

Server Page technology can also be called server scripting technology.

ASP.NET server scripting languages ​​include VB.NET, C # .NET, J # .NET, JScript.net. Microsoft's IIS Web Server supports a variety of server scripting languages, one of Microsoft's strategic decisions. Of course, since these Web service programs can only run in the IIS Web Server, you can only run on the Windows platform. It is worth noting here that the usage of ASP.NET's server script and JSP (still mentioned later XSP) are different. ASP.NET's server script and the interaction between the page elements, like the client JavaScript. No wonder, jscript.net is also included to the server script. This kind of advantage is obvious, and the ASP.NET programmer does not have to consider a lot of http request - response cycle, while JSP (or XSP) programmers must always engage this in the brain. in. JSP (or XSP) is generally only used to dynamically generate web pages, and do not perform event processing. The Java Web framework typically takes the MVC (Model - View - Control) structure, and the event mechanism for page interaction conversion is implemented in the Control section. Will explain later.

JSP's server scripting languages ​​include Java. According to the latest JSP2.0 specification (can be downloaded from java.sun.com), it can be seen that JSP is moving closer to the XML specification and introduces Expression Language and a lot of Taglib. Try to try to use Java language code from JSP page. Clear out to resolve the Java Code Pollution problem in the JSP page. The JSP page is now much better, more structured, clearer. But in my opinion, it is a part of the feature in Java Code to replace another scripting language (Taglib and Expression Language), and side effects are required to ask page design or programmers to master more languages. Moreover, in the actual application requirements, it is necessary to make this new language to meet the flexibility and power of Java languages, and may make Taglib and Expression Language become more complicated, difficult to master. Will explain later.

Another Server Page technology based on Java is XSP technology in the Apache Cocoon project. (If you need to learn more about Apache Cocoon and XSP, visit the XML.Apache.org site). Apache Cocoon project uses SAX / XSLT technology. XSP is used to provide XML content for subsequent conversion processing pipes, and the XSP page itself is generated, and there are also many XSLT conversions. The concept of taglib is also included in XSP technology, called logicsheet, and the form is similar to JSP, but the principle of implementation is completely different. JSP Taglib is implemented by Java Tag Extension Class, and XSP Taglib (LogicsHeet) is implemented by XSLT conversion. The Logicsheet mechanism of XSP technology can isolate the contents and logic of the page from physically, divide several different files. Will explain later.

ASP.NET example

Example 1. Description Service Script Calls the page_load () function (ASP.NET's embedded initialization function) Generate an example of page elements, picking out from the .NET framework document.

<% @ Page language = "c #"%> <% @ import namespace = "system.data"%>