Datasheet

Patrick c01.tex V3 - 09/18/2009 12:15pm Page 9
Chapter 1: Building Web Applications in WebLogic
Table 1-2: JSP Syntax Elements
Element Syntax Description
Scriptlet <% scriptlet code %> Java code placed directly in
_jspservice()
method at this location.
Declaration <%! declaration %> Java code placed within the generated
servlet class above the
_jspservice()
method definition. This usually defines
class-level methods and variables.
Expression <%= expression %> Java expression evaluated at run time and
placed in the HTML output.
page <%@ page
attribute=’’value’’ ... %>
Controls many page-level directive
attributes and behaviors. Important
attributes include
import
,
buffer
,
errorPage
,and
extends
.
include <%@ include
file=’’filename’’ %>
Inserts the contents of the specific file in
the JSP page and parses/compiles it.
taglib <%@ taglib uri=’’...’’
prefix=’’...’’ %>
Defines a tag library and sets the prefix
for subsequent tags.
jsp:include <jsp:include
page=’’...’’/>
Includes the response from a separate
page in the output of this page.
jsp:forward <jsp:forward
page=‘‘...’’/>
Abandons the current response and
passes the request to a new page for
processing.
jsp:useBean <jsp:useBean id=‘‘...’’
class=‘‘...’’
scope=‘‘...’’/>
Declares the existence of a bean with the
given class, scope, and instance name.
Many more elements and tags are available. A detailed discussion of these elements is beyond the
scope of this book. Consult one of the books listed at the beginning of this chapter for a complete
list of JSP elements and tags, or browse Sun’s JSP area at Link 1-2 for more information.
All Servlet Capabilities Are Available
Because JSP pages are converted to servlets, all of the capabilities and techniques available in
servlets are also available in JSP pages. The
HttpServletRequest
and
HttpServletResponse
param-
eters are available, along with a number of predefined variables available in the JSP page, as listed
in Table 1-3.
JSP scriptlet code may access these implicit objects directly because all scriptlet code is placed in
the generated
_jspService()
method code below the definition of these objects. Nevertheless, the
9