JSP Scriptlets Tag for Variable Expressions and Statements Declaration

JSP scriptlet tag

A scriptlet can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language. Within scriptlet tags, you can do any of the following:
1. Declare variables or methods to use later in the file
2. Write expressions valid in the page scripting language
3. Use any of the JSP implicit objects or any object declared with a tag.
4. Write any other statement valid in the page scripting language (if you use the Java programming language, the statements must conform to the Java Language Specification).

You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet. Scriptlets are executed at request time, when the JSP engine processes the client request. If the scriptlet produces output, the output is stored in the out object, from which you can display it.

JSP Syntax
<% code fragment %>


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

Related Topic Servlet Interview Questions & Answers
JSP Variable Declaration Statement
List of Mysql Error Code and Description
JSP Interview Questions & Answers
What is a Scriptlet

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback