JAVASERVER PAGES™ (JSP™) SYNTAX
1.All tags are case sensitive. ( a , A)
2.A pair of single quotes is equivalent to a pair of double quotes. ( '
' = " " )
3.Spaces are not allowed between an equals sign and an attribute value.
( = )
4. JSP and XML syntax cannot be mixed within a page. ( % jsp: )
5. A page in one syntax can include or forward to a page in the other syntax.
6. Some action elements have attributes whose value can be computed at
request time.
*** plain text = required bold = default bold-italics
= user-defined | = or [ ] = optional { } = required
choice ... = list of items + = can repeat
Root Defines standard elements and namespace
attributes of tag libraries.
JSP No equivalent.
XML <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" [xmlns:taglibPrefix="
URI"]+ ... version="1.2"> other elements
</jsp:root>
Comment Documents the JSP file, but is not
included in the response.
JSP <%-- comment --%>
XML No equivalent.
Declaration Declares variables or methods
valid in the page’s scripting language.
JSP <%! declaration; [ declaration
; ]+ ... %>
XML<jsp:declaration>declaration [ declaration
; ]+ ...</jsp:declaration>
Expression Contains an expression valid
in the page’s scripting language.
JSP <%= expression %>
XML<jsp:expression>expression </jsp:expression>
Scriptlet Contains a code fragment valid
in the page’s scripting language.
JSP <% code fragment %>
XML<jsp:scriptlet>code fragment</jsp:scriptlet>
Text Encloses template data
JSP No equivalent.
XML <jsp:text> template data</jsp:text>
Include Directive Includes a file, parsing
the file’s JSP elements.
JSP <%@ include file="relativeURL" %>
XML<jsp:directive.include file="relativeURLspec"
/>
Page Directive Defines attributes that apply
to a JSP page.
JSP <%@ page
[ language="java" ] [ extends="package.class" ] [
import="{ package.class | package.*} , ... "
][ session=" true |false" ]
[ buffer="none| 8kb|sizekb" ] [ autoFlush="true|false" ][
isThreadSafe=" true|false" ] [ info="text" ][ errorPage="
relativeURL " ] [ isErrorPage="true| false" ]
[ contentType="{mimeType [ ; charset=characterSet
] |text/html ; charset=ISO-8859-1}" ][ pageEncoding="{characterSet
| ISO-8859-1}" ]
%>
XML <jsp:directive.page pageDirectiveAttrList /> where pageDirectiveAttrList
is the same as the list in the JSP column.
Taglib Directive Defines a tag library and
prefix for custom tags used in the JSP page.
JSP <%@ taglib uri="URI" prefix="
tagPrefix" %>
XML No equivalent. Included in Root
< tagPrefix:name> Accesses a custom
tag’s functionality.
JSP <tagPrefix:name attribute="value"+ ...
/> | <tagPrefix:name attribute="value"+ ... >
other tags and data </tagPrefix:name>
XML Same JSP Syntax
<jsp:forward> Forwards a request to
a web resource.
JSP <jsp:forward page="{relativeURL
| <%= expression %> }" { /> | > [ <jsp:param
name="parameterName" value="{parameterValue
| <%=
expression %>}" /> ] + </jsp:forward> }
XML Same JSP Syntax
<jsp:getProperty> Inserts the value
of a bean property into the result.
JSP <jsp:getProperty name="beanInstanceName
"property="propertyName" />
XML Same JSP Syntax
<jsp:include> Includes a static file
or the result from another web component.
JSP <jsp:include page="{relativeURL | <%=
expression %>}" [ flush="true | false" ]{ />
| > [ <jsp:param name="parameterName" value="{
parameterValue
| <%=
expression %>}" /> ] +</jsp:include> }
XMLSame JSP Syntax
<jsp:plugin> Causes the execution
of an applet or bean. The applet or bean executes in the specified plugin.
If the plugin is not available, displays a dialog to
initiate the download of the plugin software.
JSP <jsp:plugin type="bean|applet" code="classFileName
" codebase="classFileDirectoryName"
[ name="instanceName" ] [ archive="URIToArchive
, ..." ] [ align="bottom|top|middle|left|right" ]
[ height="{displayPixels | <%= expression
%>}" ] [ width="{displayPixels | <%= expression
%>}"]
[ hspace="leftRightPixels" ] [ vspace="topBottomPixels
" ] [ jreversion="JREVersionNumber | 1.2" ]
[ nspluginurl="URLToPlugin" ] [ iepluginurl="URLToPlugin
" ] > [ <jsp:params>
[ <jsp:param name="parameterName"value="{parameterValue
| <%= expression %>}" /> ]+
</jsp:params> ][ <jsp:fallback> text message if plugin
download fails </jsp:fallback> ] </jsp:plugin>
XML Same JSP Syntax
<jsp:setProperty> Sets a bean property
value or values.
JSP <jsp:setProperty name="beanInstanceName
"
{ property="*" | property="propertyName
" [ param="parameterName" ] | property="propertyName
" value="{string | <%= expression%>}"
} />
XML Same JSP Syntax
<jsp:useBean> Locates or instantiates
a bean with a specific name and scope.
JSP <jsp:useBean id="beanInstanceName" scope="
page|request|session|application"
{ class="package.class"
[ type="package.class" ] | beanName="{package.class
| <%= expression %>}"
type="package.class" |type="package.class
"}{ /> | > other elements </jsp:useBean> }
XMLSame JSP Syntax