I gave a rough introduction to the servlet on the previous blog. Rough is because the blogger also just learned this part of the content, not very understand so can not speak very fine. However, in line with the 28 principle, I will continue to study first. So, this blog goes on to the JSP content. Because. The relationship between the two content is still relatively strong, the process of learning should be mutually reinforcing.
Simple Introduction Overview : JSP (Java Server page) is simply a Dynamic Web page technology. It embeds program code that generates dynamic content by embedding it in an HTML Web page. To achieve the unity of static content and dynamic content at the end of the presentation to the client.
That is to say, in the HTML page can exist the Javabean,jdbc object, EJB and other objects easy to access and produce dynamic content.
background : JSP was primarily used for the development of dynamic sites implemented by CGI (Common Gateway Interface) technology.
But because the CGI itself is relatively small, it cannot meet the increasingly complex web applications. This led to the creation of new technologies. JSP is just one of them.
Strengths :
① write once, execute anywhere: Java-based language
② Reusable Component technology: My understanding is that it's easy to introduce packaged applications
③ High efficiency and security: The JSP is compiled into bytecode before it is run. It is then interpreted by the Java virtual machine to run. Therefore, the JSP can be stored in the external transparent folder.
④ Label simplifies page development
principleIt has been mentioned before that JSP and servlet are very closely related. In fact, Sun's first development of the servlet. But the person used by the servlet should know that it is logically handled, but it is more troublesome in the output because it is CGI-oriented.
Suppose you read the principle of the servlet of a previous blog post. You will find that the differences between the two graphs are not too large.
That's because the JSP actually optimizes the servlet to be an output problem. So actually JSP is also a servlet, just a little more special. It is only compiled as a servlet class file when it is executed.
Based on the relationship between JSP and servlet, it should be very good to understand that JSP files are compiled only once. It is then stored under an incorrect outside open folder (Tomcat/work). Normally this path is empty. Only after visiting the JSP file does it exist. class files. Title The principle of execution, for example by:
Page Composition template element : mainly contains static HTML or XML content, which is an HTML framework.
Gaze : There are two types of gaze in the JSP page, one is the HTML gaze also called the display gaze. It is important to note that such a gaze can have an expression. There is also a JSP hidden gaze, which is ignored at compile time.
So, the first one is visible when the browser views the source file, while the hidden gaze is invisible.
What is this for? Be able to think for a moment ... This makes it clear that the understanding of the JSP page composition should be possible.
script elements : Contains declarations (Declaration), expressions (expression), script programs (scriptlet).
directive Element : The directive element of the JSP is used to set the global variables of the page, declare the class and implement related properties. It is only valid within the page range.
There is a need to distinguish it from the statement.
action Elements : JSP actions use XML syntax formatting tags to control the behavior of the servlet engine.
The ability to dynamically insert files, redirects and other functions.
built-in objects the built-in object of a JSP is the following nine types of objects that can be used directly on a page without the need to display a declaration. There is no need to show the reason for the declaration because. These nine types of objects are instantiated internally when the servlet is instantiated. (Photo from: "Web2.0 dynamic Site development: JSP Technology specific interpretation and application practice")
finally : for the page composition and built-in object is simply a mention, no specific explanation.
Not necessarily, it is important to understand how the JSP is executed and its position, function, and role in a single request. And then, just left a thought in front about the two gaze elements. First, the JSP page contains HTML and HTML is a markup language, it is not compiled so naturally it is impossible to ignore the content of the gaze. The hidden gaze is not. It needs to be compiled, and it is hidden from being ignored at compile time. That is, JSP is a combination of different elements. Therefore, there will be different treatments. Should almost be the same. There should be nothing to say about the built-in objects.
Java Web Development Fundamentals (2)-jsp