SP Notes
<%--*****--%> is an annotation character.
instruction Element
the
directive element is used to specify information about the Web page itself. For example:
<%@ page contenttype= "text/html"%>
The
instruction element begins with the <%@, ending with%>. Page is the instruction name, contenttype is a property name of the page directive, and "text/html" is the property value. Directive elements are case-sensitive. The settings for this directive specify the page content type. If you do not set the ContentType property, the default value is text/html.
other attributes of the
page directive and Errorpage,iserrorpage,session,pageencoding,buffer,autoflush,
Language,import property.
Other instruction elements and
.
<%@ include ...%> introduces a file in the translation phase
<%@ taglib ...%> declares a tag library used by a page that contains custom behavior.
Taglib need to explain the following example:
<%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core" %>
The
URI represents the Jstl library provided by Sun. The value of the prefix represents the library that the URI refers to. Used in the behavior element that follows. For example:
<%@ page contenttype= "text/html"%>
<%@ taglib prefix= "C" uri= " http://java.sun.com/jsp/jstl/core"%>
<title>jsp is easy</title>
<body bgcolor= "White" >
are as easy as ...
<%--Calculate The sum of 1 + 2 + 3 dynamically--%>
1 + 2 + 3 = <c:out value= "${1 + 2 + 3}"/>
</body>
The
<c:out represents an Out object in the Jstl library.
Behavioral Element
An element that performs certain actions when a browser requests a page, called a behavior element. The JSP defines some standard behavior elements, as follows:
<jsp:useBean> make a JavaBeans component available on this page
<jsp:getProperty> obtains a property value from a JavaBeans component and adds it to the answer
<jsp:setProperty> Set JavaBeans property value
<jsp:include> introduces an answer result from a servlet or JSP page in the request processing phase
<jsp:forward> forwards processing of requests to a servlet or JSP page
<jsp:param> Use <jsp:include> or <jsp:forward> to transfer a request to another servlet or JSP page, add a parameter value to the request.