1. Dynamic page Technology (JSP)
What's a JSP? Java Server page Java servers pages technology.
JSP includes the static part and the dynamic part, runs in the server.
The HTML contains the Java code that must be run on the server to complete the translation, compile, run process, and finally return the HTML to the client.
Finally, Java is generated, and the class files are placed in Tomcat's work directory.
work/catalina/localhost/Project name/org/apache/jsp/page name _jsp.java and this Java file is a final class.
2, JSP page composition: template elements, JSP elements
Template elements: HTML, CSS, JavaScript, etc.
JSP elements: script elements, annotation elements, instruction elements, action elements
Script elements: script segments, declarations, expressions, EL
variables defined in a small script are local variables, where methods cannot be defined
A variable defined in a declaration is a global variable that can define a method , and any user's actions on the global variables of a JSP page will affect other users
3, the use of script paragraph syntax: <% legal code snippet; %> each JSP page can use any number of script segments
4, the use of the statement syntax: <%! Statement 1; Statement 2; ......%>
5. Expression: <%= valid Java expression (cannot end with no seal)%>
6, some practical grammar of the small summary:
<!-- - -HTML annotations
<%= - %> expression
<% %> script segment
<%! %> statement
<%-- --%> jsp annotations
<%@ %> Directive element
7, the main three kinds of instruction elements: page, include, taglib
Properties of the page directive : Language: Language used with scripting elements
Pageencoding: Character encoding
ContentType: Type and encoding format of output content
Info: page-related descriptive information
Import: The Java class package required for importing pages
Session: Sets whether the built-in session object of the current page is available
Iserrorpage: Specify whether the page is an exception handling page
Buffer: Sets the size of the out-of-object's buffers or does not use buffers
Include: The role of the JSP page appears at the location of the directive, static contains a file (must be able to be parsed by the JSP and the current JSP page in a page).
Static include: The current JSP page and the inserted part of the composition of a new JSP page, and then the JSP engine to translate the JSP page into a Java class file, note: Only in the work directory to generate a Java class file
Problems that occur: the same variables appear in the current JSP page and in the inserted part of the page, resulting in a compilation error
Taglib: The definition used to introduce the required tag library to a JSP page, with the following syntax:
<% @taglib uri= "tag library URI address" prefix= "prefix name"%>
8, the JSP nine large built-in objects--------out
The Out object is primarily used to output data to the browser, common methods: Print (), println (), Close ()
The difference between the print and println methods: instead of displaying the page wrapping, the resulting HTML source line wraps
Here's a look at the example: JSP code
Look at the results of running in the browser:
It doesn't look any different, it's different in the source code.
All right, next time, write the other built-in objects and action elements.
JSP basic syntax