JSP files are composed of two types: JSP elements and HTML templates.
HTML templates are mainly used for static Web page display. Based on HTML templates, JSP elements related to dynamic web pages are added to achieve dynamic web page interaction.
Simply put, JSP files are HTML files embedded in Java code.
JSP elements include the following four types:
Command element: used to provide information about the entire JSP page, such as the character set used by the page and the language used by the script; script element: embedded Java code, used to achieve dynamic interaction of the page; Action element: it mainly refers to some action tags used to complete some actions, such as page forwarding and parameter transmission. annotation elements: Used to comment some content in JSP pages.
Page command
<% @ page language = "scriptingLanguage" extends = "className" import = "importList" session = "ture|false" buffer = "none|sizekb" autoFlush = "true|false" isThreadSafe = "true|false" info = "info_text" errorPage = "error_url" isErrorPage = "true|false" contentType = "ctinfo" pageEncoding = "peinfo" isELIgnored = "true|false"%>
Include command
<% @ include file = "relativeURLspec"%>
Taglib command
<% @ taglib uri = "uriValue" prefix = "prefix"%>
Script element:
Declaration: variables, methods, and classes can be defined. It can be understood as a global variable. <%! Declaration %> JSP expression: After the expression is executed, the result is returned to the client. <% = Expression %> script code: the Java code to be executed during client request processing. <% Scriptlet %>
Action element:
<JSP: Include>: Used to dynamically add resource files to the current page. <JSP: Forward>: used to control page forwarding. <JSP: param>: used to pass parameters, embedded in <JSP: Include>, <JSP: Forward>, and <JSP: Params>. <JSP: plugin>: it is used to load and run a Java program (applet or JavaBean) in a browser; <JSP: Params>: used to pass parameters, which can only be used in <JSP: plugin>; <JSP: fallback>: used to specify the prompt information displayed when the Java Plug-In fails to run normally. It can only be used in <JSP: plugin>. <JSP: usebean>: used to obtain the JavaBean object; <JSP: setproperty>: Used to set attribute values for the JavaBean object; <JSP: getproperty>: used to read the attribute values of the JavaBean object.