Jsp elements include:
I. jsp page
1. Comment
Visible comment html comment, visible in the browser, insecure
<! -- Comment -->
Java comments are normal, invisible to the browser, and secure, but they violate the Java and html code separation principles.
<% // Comment> or <%>
Hide comment JSP comments, invisible to the browser, secure, recommended
<% -- Comment -- %>
2. Commands
<% @... %>
Page is not unnecessary. It acts on this jsp page and does not contain <jsp: include> incoming pages. Only the import attribute can be repeated.
<% @ Page
Extends = "class name" // The Custom parent class must implement the javax. servlet. HttpJspPage interface.
Improt = "java package list" // multiple packages separated by commas
Session = "true | false" // whether the session object is built in
Buffer = "none | 8KB | custom size" // out object buffer size
False "// indicates whether to automatically flush data. If false is used, an exception is thrown.
InThreadSafe = "true | false" // tell the server whether your thread is secure. If it is false, concurrent threads are not supported.
Info = "page info" // It can be obtained through getServletInfo ()
ErrorPage = "error page url" // page to be switched when a page exception occurs
IsErrorPage = "true | false" // if it is true, the built-in object Exception can be used. If it is false, it cannot be used. The default value is false.
ContentType = "text/html; charset = ISO-8849-1" // MIME type and character set for "output to client", default: <--
PageEncoding = "char encoding type" // character set encoding on the JSP page
IsELIgnored = "true | false" // whether EL expressions are supported
%>
Include contains static files (jsp, html, txt, java ...),
<% @ Include file = "URL" %>
Cannot contain URL variables, such as: <% @ include file = "<% = Expression %>" %>
Files that cannot be contained are followed by any parameters. For example: <% @ include file = "index. jsp? Name = user "%>
Avoid using tags such as We recommend that you end the file suffix with "f" (fragment), such as jspf, to prevent the jsp compiler from compiling the file.
Include commands and jsp: include action differences see: http://blog.sina.com.cn/s/blog_73cdc7a601018x7l.html
Use taglib to declare a custom tag Library
<% @ Taglib uri = "URI To Tag Library" prefix = "pubtag" %>
3. script elements
Statement
<%! Declaration; [declaration;] +... %>
Declared classes, methods, and variables are shared globally, and threads are not secure.
Expression
<% = Java expression %>
The expression ends with a semicolon and is equivalent to <% out. print (expression); %>. It can be used as the attribute value of other jsp elements.
Script Applet
<% Java code %>
The Java statements in Scriptlet are not necessarily complete. The declared variables are local variables.
4. template data
Action
Standard action
Jsp: include: the request stage contains static or dynamic resources. It can only access JspWriter and cannot set response headers or cookies, which is less efficient than include commands,
<Jsp: include page = "URL | <% = Expression %>" flush = "true"> // The default flush value is false. true is required.
[<Jsp: param name = "param name" value = "param value | <% = Expression %>"/>]? +
</Jsp: include>
Jsp: forword: forward the request to another resource. The resource must be in the same context as the request sender. In this case, the request is forwarded immediately.
<Jsp: forword page = "URL | <% = Expression %>">
[<Jsp: param name = "param name" value = "param value | <% = Expression %>"/>]? +
</Jsp: forword>
Jsp: useBean
<Jsp: useBean
Id = "beanId"
Class = "package. class" // instantiate class
Scope = "request" // scope. The default value is Page.
Type = "superclass or interface" // type of the interface or superclass
/>
Jsp: setProperty
<Jsp: setProperty
Name = "bean name" // name of the bean to which the property belongs
Property = "property name" // property name
Value = "str" // attribute value, which can also be an EL expression
/Jsp: setProperty>
You can use the wildcard "*" to set the JavaBean attribute value with the same name as the HTTP Form attribute, for example:
<Jsp: setProperty name = "user" property = "*"/> to replace:
<Jsp: setProperty name = "user" property = "name" value = "<% = Request. getParameter (" name ") %>"/>
<Jsp: setProperty name = "user" property = "password" value = "<% = Request. getParameter (" password ")/>
If you have different names, you can use the Request parameter settings, such:
<Jsp: setProperty name = "user" property = "name" param = "username"/>
Jsp: getProperty
<Jsp: getProperty
Name = "bean name" // name of the bean to which the property belongs
Property = "property name" // property name
/Jsp: getProperty>
Jsp: the scope of the new param parameter is </jsp: include> and </jsp: forword>.
<Jsp: param name = "param name" value = "param value | <% = Expression %>"/>
Jsp: plugin
<Jsp: plugin type = "Applet | Bean" codebase = "URL">
[<Jsp: param name = "param name" value = "param value | <% = Expression %>"/>]? +
[<Jsp: callback> arbitary_text </jsp: fallback>]? +
</Jsp: plugin>
Note:
1. When the include command is used, the included and included files must be encoded in the same way.
2. The <jsp: forward> and <jsp: include> commands can be used to share beans within the scope of the Request.