Contents | Prev | Next


Scriptlet

Contains a code fragment valid in the page scripting language.

JSP Syntax

<% code fragment %>

XML Syntax

<jsp:scriptlet>	
   code fragment	
</jsp:scriptlet>

Examples

<%	
   String name = null;	
   if (request.getParameter("name") == null) {	
%>	
	
<%@ include file="error.html" %>	
	
<%	
   } else {	
   foo.setName(request.getParameter("name"));	
   if (foo.getName().equalsIgnoreCase("integra"))	
      name = "acura";	
   if (name.equalsIgnoreCase( "acura" )) {	
%>

Description

A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language.

Within a scriptlet, you can do any of the following:

Any text, HTML tags, or JSP elements you write must be outside the scriptlet.

Scriptlets are executed at request time, when the JSP container processes the request. If the scriptlet produces output, the output is stored in the out object.

See Also



Contents | Prev | Next

Copyright © 2002, Sun Microsystems, Inc. All rights reserved.