You are on page 1of 2

scriptlet

Directives Contains a block of scripting code. A JSP page can


contain multiple blocks of scripting code.
page <% script code %>

Defines page-wide attributes. Example:


<%@ page attribute="value" ... %> <% String greeting =
request.getParameter("Greeting");
attributes, with default values, are: out.println(greeting); %>

JSP Quick Reference Card attribute = language="java" | session="true"


| contentType=text/html;charset="ISO-8859-1" expression
| import="package(s)" | buffer="8kb"
Basic Syntax | autoflush="true" | isThreadSafe="true" Defines statements evaluated on the server before
| info="text_string" | errorPage="relativeURL" sending the page output to the client.
| isErrorpage="true" | extends="class_name"
<%= expression %>
Default scripting language value = a string literal in single or double quotes.
Example:
The scripting language of a JSP page defaults to Java.
Insert the following line in a JSP page to configure the
include <%= myVar1%>

page to use JavaScript: Inserts text into a JSP page.


<%@ page language = "javascript" %> <%@ include file = "path" ... %> Actions
Using white space taglib jsp:include
White space contained within the template code is Defines a custom tag library used by a JSP page. Call one JSP page from another. Upon completion, the
returned to the client as it was entered in the JSP.
<%@ taglib uri="tagLibraryURI" destination page returns control to the calling page.
prefix="tagPrefix" %>
Quoting attribute values <jsp:include page="path" flush="true"/>
After the taglib directive, reference the custom tags
Quote attribute values, using either single or double using the syntax: <jsp:include page="path" flush="true">
quotes, to all JSP elements. For example: <jsp:param name="paramName"
<tagPrefix:tagName> value="paramValue" /> ...
<%@ page contentType = "text/plain" %> ... </jsp:include>
</tagPrefix:tagName>
Writing comments for the JSP jsp:forward
A JSP comment is not output to the client as part of the Scripting Elements Calls one JSP page from another. Execution of the calling
JSP page’s output. page is terminated by the call.
<%-- Comment string... --%> declaration <jsp:forward page="path" />

Outputting comments to the client Creates page-wide definitions such as variables.


<jsp:forward page="path">
<%! declaration %> <jsp:param name="paramName"
HTML comments are output to the client. value="paramValue" /> ...
Example: </jsp:forward>
<!-- comments -->
<%! private String foo = null;
public String getFoo() {return this.foo;} %>
jsp:plugin jsp:setProperty pageContext
Enables you to invoke an applet on a client browser. Sets the value of one or more properties in a bean. The page context for the JSP.
<jsp:plugin <jsp:setProperty name="beanName " prop_expr /> Java type: javax.servlet.jsp.PageContext
type="bean|applet"
prop_expr has one of the following forms:
code="objectCode" request
codebase="objectCodebase" property="*" |
{ align="alignment" } property="propertyName"| The client request.
{ archive="archiveList" } property="propertyName" param="parameterName"|
{ height="height" } property="propertyName" value ="propertyValue" Java type: javax.servlet.HttpServletRequest
{ hspace="hspace" }
{ jreversion="jreversion" } jsp:getProperty response
{ name="componentName" }
{ vspace="vspace" } Writes the value of a bean property as a string to the out The response to the client.
{ width="width" } object.
{ nspluginurl="url" } Java type: javax.servlet.HttpServletResponse
{ iepluginurl="url" } > <jsp:getProperty name="name"
{ <jsp:params> property="propertyName" /> session
{ <jsp:param name=" paramName"
value="paramValue" /> }+ The session object created for the requesting client.
</jsp:params> } JSP Objects
Java type: javax.servlet.http.HttpSession
{ <jsp:fallback> arbitrary_text
</jsp:fallback> } > See the corresponding Java object type for the available
</jsp:plugin> methods for these objects. Allaire Contact Information
The elements in brackets ({}) are optional.
application
Allaire Web sites
jsp:useBean The servlet context obtained from the servlet
configuration object. Main Allaire Web site:
Defines an instance of a Java bean.
Java type: javax.servlet.ServletContext www.allaire.com
<jsp:useBean id="name"
scope="page|request|session|application" JRun Development Center:
typeSpec /> config
www.allaire.com/developer/jrunreferencedesk/

<jsp:useBean id="name" The ServletConfig object for the JSP page. JRun Developer Forum:
scope="page|request|session|application" Java type: javax.servlet.ServletConfig forums.allaire.com/jrunconf
typeSpec >
body
</jsp:useBean>
exception Allaire technical support
typespec is any one of the following: The uncaught exception that resulted in the error page Allaire offers a range of telephone and Web-based
class="className" |
being invoked. support options. Go to http://www.allaire.com/support
class="className" type="typeName" | Java type: java.lang.Throwable for a complete description of technical support services.
beanName="beanName" type=" typeName" | You can make postings to the JRun Support Forum
type="typeName" out (http://forums.allaire.com) at any time.

An object that writes into a JSP page’s output stream. JRun is a trademark of Allaire Corporation. All other trademarks are
property of their respective holder(s.)
Java type: javax.servlet.jsp.JspWriter © 2001 Allaire Corporation. All rights reserved.
Part number: AA-JRQRF-RK

You might also like