This section lists and describes the directives, implicit objects, scripting
elements, and standard actions included in DB2 Everyplace JSP support.
Directives
Page directive
- Description
- The page directive defines page-dependent attributes.
- Syntax
-
<%@ page page_directive_attr_list %>
page_directive_attr_list ::=
{language="scriptingLanguage"}
{extends="className" }
{import="importList" }
{contentType="ctinfo" }
- Attributes
- The four valid attributes for this directive are:
- language - Must be 'java' if specified.
- extends - A fully qualified Java programming language class name
that names the superclass of the class to which this JSP page is
transformed.
- import - The default import list is
com.ibm.db2e.jsp.server.*,
java.io.*, java.sql.*, and
java.util.*.
- contentType - Can be any value (such as text/html, text/xml,
application/x-octet).
- Example
-
<%@ page contentType="text/html" %>
Include directive
- Description
- Use the include directive to include data in a JSP page. The
included file may have elements which will also be processed.
- Syntax
-
<%@ include file="relativeURLspec" %>
- Attributes
- The attribute for this directive is file which must be a
page-relative path. The path cannot not start with a "/", and is to be
interpreted relative to the current JSP page.
- Example
-
<%@ include file="copyright.html" %>
Implicit objects
When you create JSP pages, you have access to certain implicit
objects. They can be used within scriptlets and expressions, without
first being declared. Each implicit object has a class defined in a
core Java technology or
com.ibm.db2e.jsp.server package, shown
in Tabelle 13.
Tabelle 13. Implicit objects
Implicit Variable
| Type
| Representation
| Method Summary
|
request
| com.ibm.db2e.jsp.server.MiniHttpRequest
| The request for the JSP page.
|
java.lang.String getParameter(java.lang.String name)
java.lang.String getQueryString()
|
response
| com.ibm.db2e.jsp.server.MiniHttpResponse
| The response to the request
|
java.lang.String encodeURL(java.lang.String url)
void setDateHeader(java.lang.String name, long date)
void setHeader(java.lang.String name, java.lang.String value)
|
in
| java.io.BufferedReader
| This object is currently unavailable.
|
|
out
| java.io.PrintStream
| An object that writes into the Web browser.
|
|
config
| com.ibm.db2e.jsp.server.DB2eJspConfig
| The DB2eJspConfig for this JSP page.
|
java.lang.String getInitParameter(java.lang.String name)
|
exception
| java.lang.Throwable
| An exception thrown during execution of the JSP page.
|
|
- Anmerkung:
- Some of the types for the implicit objects above differ from those in JSP
1.1 due to the implementation of DB2 Everyplace JSP support.
Scripting elements
Declarations
- Description
- Use declarations to declare Java variables and methods used in a JSP
page. Declarations are member variables (fields and methods) of the
Java class for the JSP page.
- Syntax
-
<%!declaration(s) %>
- Example
-
<%!
String name = "Joe Smith";
public String getName() {
return name;
}
%>
Standard actions
<jsp:useBean>
- Description
- A jsp:useBean action associates an instance of a Java programming
language object defined within the "page" scope available with a given id via
a newly declared scripting variable of the same id.
- Syntax
-
<jsp:useBean id="name" scope="page|request|session|application" typeSpec/>
typeSpec ::=
class="className"
- Attributes
- The three attributes for this tag are:
- id - Specifies the identifier of this bean. Do not reuse
this name in the JSP page. This attribute is required
- scope - This attribute is ignored if specified. The
default scope "page" is used.
- class - Specifies the class that this bean represents.
This attribute is required.
- Example
- <jsp:useBean id="masterViewDBBean"
class="Query1HTMLResultsMasterViewBean" />
<jsp:setProperty>
- Description
- The jsp:setProperty action sets the value of properties in a
Bean.
- Syntax
-
<jsp:setProperty name="beanName" prop_expr />
prop_expr ::=
property="propertyName" value="propertyValue"
propertyValue ::= string
The value propertyValue can also be a request-time attribute value.
propertyValue ::= expr_scriptlet
- Attributes
- The three attributes for this tag are:
- name - The name of a Bean instance defined by a
<jsp:useBean> element before this action appears. The Bean
instance must contain the property you want to set. This attribute is
required.
- property - The name of the Bean property whose value you want to
set. This attribute is required.
- value - The value to assign to the given property. This
attribute can accept a request-time attribute expression as a value.
This attribute is required.
- Example
-
<jsp:setProperty name="masterViewDBBean" property="username"
value='<%=config.getInitParameter("username")%>' />
Scriptlets
- Description
- Use scriptlets to hold any valid Java code fragments. These code
fragments are placed in the source code for the JSP page, and are relative to
other elements of the JSP page.
- Syntax
-
<% scriptlet %>
- Example
-
<%
try {
String name = Query1DBBean.getString(1);
out.println("Name = " + name);
}
catch (SQLException e) {
}
%>
Expressions
- Description
- Expressions are string representations of data types. You can use
expressions in queries and in HTML comments. The application evaluates
the expressions at run-time and converts the expressions into strings.
- Syntax
-
<%= expression %>
- Example
-
<%= new java.util.Date() %>
Note: Variable names that begin with __db2ejsp__
are keywords and are used internally. Do not use these variables in the
JSP page.
Zugehörige Konzepte
Zugehörige Tasks
Zugehörige Referenzen