The following code demonstrates an example of the JavaFX process command line parameters. You can refer to it.
1. Overview
A JSP file is a file formed by combining three major instructions, nine major objects and JSP expressions with HTML statements. Its essence is a Servlet. To put it simply, it is Java code + HTML statement.
2. Operating principle
When each JSP page is accessed, it is translated into a Servlet source program by the JSP engine, and the source program is then compiled into a Servlet class file. The subsequent execution process is consistent with the execution of ordinary Servlet. The Servlet engine loads class files and translates them for execution.
3. Nine objects
JSP has 9 built-in objects, which can be used without declaration.
(1) request: actually HTTPServletRequest.
(2) response: actually HTTPServletResponse.
(3) pageContext: represents the current JSP page, contains almost all the information of the current JSP page, and eight other objects can also be obtained from this object.
(4) session: represents a session between the browser and the server, and is an object of HttpSession.
(5) out: You can directly output text information or HTML code on the page through the method of this object.
(6) application: represents the current WEB application and is a ServletContext object.
(7) exception: After declaring , exception information can be output through this object.
(8) config: The ServletConfig object of the Servlet corresponding to the current JSP. If you want to access the configuration parameters of the current JSP, you need to map the access.
(9) page: A reference to the Servlet object corresponding to the current Jsp, but of object type.
The four most commonly used and important objects are as follows according to their scope:
pageContext: The scope is the current JSP page. Variables in files introduced through can also be accessed on the current page. However, the variables and parameters introduced into the file through pageContext.include("file") cannot be directly used and modified on the current page. The essence of this method is to add the contents of the file to the current page intact, which can be understood as adding HTML The page is spliced ??directly at this location.
request: scope is always valid during the request forwarding process.
Session: The scope is a session between the browser and the server. This is intuitively reflected in the opening and closing of the browser. Application cases include the implementation of shopping carts in shopping websites.
Application: Valid when the current application is loaded in the server. The application will be uninstalled or reloaded from the server, and the server will be shut down, etc., which will cause the object to become invalid. Application examples include website statistics on the number of visitors.
Methods related to attributes:
Object getAttribute (String name) Gets the specified attribute
Enumerration getAttributeNames () Gets the Enumeration object consisting of all attributes
name, Object o) Set attributes
4. Three major instructions
(1) page: declare page information or import content
?、?The jar package required to import the file. Externally added jar packages are generally stored under the Web project WEB-INFlib,
<%@ page import="java.util.*"%>
② Close the session, and the session is open by default.
<%@ pagesession="false" %>
?、?If there is an error on the current page, jump to the "file" page. And the jump method is request forwarding.
<%@ page errorPage="file"%>
④ The "file" page above can handle or explain page errors and can be used with the exception object.
<%@ page isErrorPage="true"%>
?、?The character encoding of the current JSP page (JSP file encoding)
<%@ page pageEncoding="utf-8"%>
⑥ The response type of the current JSP page (the content encoding sent by the server to the browser)
<%@ page contentType="text/html; charset=utf-8"%>
?、?Whether to use EL expression, usually false
<%@ page isELInored="false" %>
⑧ To specify the information of the JSP page, you can use the getServletInfo() method to obtain the string
<%@page info="this JSP info" %>
(2) include instruction: include other files and merge them with the current page. Such files usually include text, JSP or other format files.
?、?Static introduction: Notify the JSP engine to merge other source files into the Servlet source file converted from the current JSP page when translating the JSP page. The two source files are merged into one Servlet source file. "file" is a relative path.
<%@ include page="file"%>
?、趧討B(tài)引入:該句被執(zhí)行時程序通過請求轉(zhuǎn)發(fā)跳轉(zhuǎn)到"file",執(zhí)行當(dāng)中的內(nèi)容之后再返回執(zhí)行當(dāng)前頁面的剩余部分,實際是兩個Servlet源文件
<jsp:include page="file"></jsp:include>
(3) taglib: 能夠讓用戶根據(jù)需求自定義新的標(biāo)簽,便于功能的實現(xiàn),但因此也導(dǎo)致了代碼易讀性不高。
5.其它
(1) JSP表達(dá)式:可以直接將表達(dá)式中的內(nèi)容顯示在瀏覽器中
<%= "Hello World!" %>
?。?) 聲明函數(shù)
<%! pulic void function(){ out.println("Hello World!"); }%>
?。?)注釋
<!-- 客戶端注釋,客戶端查看源可以看到 -->
<%-- 服務(wù)端注釋,客戶端查看不到 --%>

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)