Simple JSP exercises-JSP commands, jsp-jsp commands
I. page commands:
When defining the global attribute value of a JSP page, you can use the page command to place it in the header of the page. For example:
<%@ page contentType="text/html; charset=gb2312" %>
Note: The contentType attribute in the page command cannot be specified twice on the same page.
The page directive has many attributes. The attribute enclosed by square brackets "[]" indicates the optional attribute.
1. language:
Language defines the script language used on the page. The default value is java. Therefore, this attribute does not need to be set when writing JSP programs.
2. import:
Import attributes are commonly used. It is used to import the packages or classes to be used in the program. This attribute can have multiple values. Both the built-in classes in the java core package and the classes written by the user must be referenced in the import so that this class can be used in JSP programs.
3. contentType:
The contentType attribute sets the MIME (Multipurpose Internet Mail Extention) Type of the JSP page. Set the format to "MIME" or "MIMI type; charset = encoding ". By default, the characters set on the JSP page are encoded as ISO-8859-1, that is, type = "text/html; charset = ISO-8859-1 ".
4. session:
The session attribute specifies whether to use the session object on the JSP page. If this parameter is set to false, the session object and the scope = session JavaBean or EJB cannot be used in the JSP program. The default value of this attribute is true.
5. buffer:
The buffer value can be none, 8 kb, or a given kb value. If the value is none, it indicates that no cache is available and is directly output to the browser of the client, this attribute is used to set the buffer size of the out object cache.
6. autoFlash:
The autoFlash attribute specifies whether the buffer is automatically refreshed when the buffer is full. If the value is false, an exception occurs when the buffer overflow occurs. If the buffer value is set to none, the value of this attribute cannot be set to false. The default value of this attribute is true.
7. isThreadSafe:
The isThreadSafe attribute sets whether the JSP page can be accessed by multiple threads. If the value is true, the JSP page can respond to requests from multiple customers at the same time. If the value is false, only one customer's request can be processed at a certain time. The default value of this attribute is 0.
8. info:
The info attribute sets the information string of the JSP page, which can be descriptive text of this JSP page. You can use the getServletInfo () method to obtain this string. Why is it getServletInfo? Because the JSP Engine converts JSP to Servlet and then responds to client requests.
9. errorPage:
The URL of the page to be redirected when an error occurs in the errorPage attribute settings.
10. isErrorPage:
Whether the isErrorPage attribute is set to an error page. If the value is true, the exception object can be used. If the value is false, the exception object cannot be used. The default value is false. Therefore, you must set this attribute to true in the page command on the JSP page of the exception object.
Ii. include command:
The include command is used to insert a static file in this command. This is similar to the # include command in C language. It only combines the file code with this file to form a large program file. The syntax format of the include command is as follows:
<% @ Include file = "file path" %>
File paths generally use relative paths, so that migration of program code files will not be affected. If the path starts with "/", it indicates that the root directory path relative to the JSP server application is used. If the path is in the format of file name or folder name + file name, it indicates the relative path relative to the current directory of the JSP file. Make sure that the contained file is consistent with the syntax of the contained file. When using the include command, make sure that the include command is in a proper position.
JSP instruction exercises
B
Is the top of the jsp file <% page... %>
Jsp programming exercises I need some simple JSP programming exercises and answers
I have some are long ago, my mailbox crazyCyan@163.com contact me to send you