A. JSP directives are used to set the entire JSP page related properties
Directives can have many properties, which exist as key-value pairs and are separated by commas.
Three types of directive tags in JSPs:
page directive
The page directive provides the container with instructions for using the current page. A JSP page can contain multiple page directives.
Syntax format for page directives:
<%@ page attribute= "value"%>
Properties
The following table lists the properties that are related to page directives:
For example:
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"ErrorPage="showerror.jsp"%><%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"Iserrorpage="true"%>
Settings for buffers
<%@ Page Language="Java"pageencoding="gb2312"AutoFlush="true"Buffer="8kb" %>
include Directives
JSPs can include other files through the include directive. The included file can be a JSP file, an HTML file, or a text file. The contained file is as if it were part of the JSP file and will be compiled at the same time.
<% @ include file = " file relative URL address " %>
two. JSP action Elements
JSP actions can dynamically insert files, reuse JavaBean components, redirect users to additional pages, and so on.
<attribute= "value"/>
Several commonly used are as follows:
< Jsp:include ></ Jsp:include > < page= "include1.jsp"></jsp:include> tag Dynamic loading, can be with parameters or without parameters
Pass Value:
<page= "include2.jsp"><Jsp:param Name= "username" value= "PKD"/></JSP: Include>
Value:
<% out.println (request.getparameter ("username")); %>
<jsp:forward></jsp:forward>
<page= "index.jsp"></jsp:forward> tags jump directly to a page, with parameters, or without parameters
Pass Value:
<% int Age= About; %> <Jsp:forwardpage= "forword1.jsp"> <Jsp:paramvalue= "<%=age%>"name= "Age"/> <Jsp:paramname= "User"value= "PKD"/> </Jsp:forward>
Value:
<%=Request.getparameter (" Age") %><BR/> <%=Request.getparameter ("User") %>
JSP in Javabean Use
Define assignment:
<Jsp:usebeanID= "Students"class= "PCTC." Studentsbean "> <Jsp:setpropertyname= "Students" Property= "FirstName"/> <Jsp:setpropertyname= "Students" Property= "LastName"/> <Jsp:setpropertyname= "Students" Property= "Age"/> </Jsp:usebean>
Attribute value:
<name= "Students" Property= "FirstName"/> <name= "Students" Property= "LastName"/> < name= ' Students ' Property= ' age '/>
Method:
<% = %>
Job: Show the records in the database in the page, according to the age of the teacher 30 and salary >3000, with the javabean tag to achieve
JSP6 (JSP instruction and JSP action Element)