Your review is Submitted Successfully. ×
4.4

Summary

Arsenal Football Team
j n@janfigo
Sep 05, 2004 12:17 PM, 4260 Views
(Updated Oct 15, 2007)
GUNNERS --- on a roll!!!

List of JSP elements and their

default values


JSP tag type

Description

Tag syntax

Directive

Specifies

translation time instructions to the JSP engine

<%@

Directive %>

Declaration

Declares

and defines methods and variables

<%!

Declaration %>

Scriptlet

Allows

the developer to write Java code in a JSP page

<%

Java code %>

Expression

Used to

print values in the output HTML of the JSP page

<%=

Expression %>

Action

Specifies

request time instructions to the JSP engine

<jsp:actionName

/>

Comments

General

comments used in documentation and debugging

<%--

Comment --%>

List of attributes of the page

directive, and their default values.


The

syntax of the page directive is as follows:

<%@

page {attribute-list} %>

where

attribute-list is the list of attribute-value pairs as defined in the table

below.

* If

multiple attributes are defined within the same page directive, then they must

not be comma-separated.

e.g.

<%@ page buffer=”8kb”, session=”true” %>

The page

directive defined above is Invalid, as the two attributes, buffer and session

are separated by a comma.

* If the

import attribute has multiple packages, then all packages must be within the

same string, and must be comma separated.

e.g.

<%@ page import=”java.util.*”, ”java.text.*” %>

This is

Invalid. The correct syntax is as follows,

<%@

page import=”java.util.*, java.text.*” %>

Attribute Name

Description

Default Value

import

Comma

separated list of Java classes and

Packages

that will be used in the JSP page

java.lang.*

javax.servlet.*

javax.servlet.http.*

javax.servlet.jsp.*

session

Boolean

literal, specifies whether the JSP page will take part in an HTTP session

True

errorPage

Specifies

the URL to another JSP, which is capable of handling exceptions

Null

isErrorPage

Boolean

literal, specifies if the current page is capable of handling exceptions

False

language

Scripting

language used by the JSP engine

Java

extends

Any

valid Java class that extends javax.servlet.jsp.JspPage

Implementation

dependent

buffer

Specifies

the size of the output buffer. Value defined is in Kb, and the suffix kb is

mandatory. If no buffer is required, specify the String “none”

Implementation

dependent

autoFlush

Boolean

literal, specifies if the buffer should be flushed when full

true

isThreadSafe

Boolean

literal, specifies if the JSP page is thread safe

true

info

Information

about the JSP page

Implementation

dependent

contentType

Mime

type and character encoding for the output

text/html;charset=ISO-8859-1

pageEncoding

Character

encoding of the JSP page

ISO-8859-1

JSP

Life-Cycle stages

Lifecycle stage

Description

Page

Translation

The JSP

page is parsed and a Java file containing the corresponding servlet is

created.

Page

Compilation

The JSP

engine compiles the generated servlet file into a class file. The compiler

used is the javac compiler or any vendor specified compiler.

Load

the class

The

compiled class is loaded.

Create

an instance

An

instance of the servlet class is created.

Call

jspInit method

This

method is called before any other method, to allow initialization.

Call

_jspService method

This

method is called for each request. Do not override this method. The JSP

engine does it during the page translation phase.

Call

jspDestroy method

This

method is called when the servlet container takes the servlet out of service.

Translation Process:

The JSP

engine parses the JSP page and applies the following rules for generating the

servlet.

This is

the first stage in the Lifecycle of a JSP. During this stage, the JSP engine

reads the JSP page, parses and validates it. The JSP engine checks the syntax

of all the tags used. In addition, it also checks if the same Java bean is not

defined more than once in the translation unit. Variables are not defined more

than once, and if any custom tags are used, then they must be properly

formatted, and the tag library must be valid.

Compilation:

The

servlet generated during the translation phase gets compiled into a class file,

using the javac compiler (or any other vendor specific compiler). The scripting

language (Java) errors are caught during the compilation phase. All the Java

code written between scriptlets, expression and declarations is compiled during

this phase.

Loading and Instantiation:

After

compilation, the servlet container loads the servlet class into memory and

instantiates it.

 

 

 

Implicit variables and implicit

objects available in a JSP page.


 

Identifier name

Class or Interface

Description

application

javax.servlet.ServletContext

Refers

to the web application’s environment

session

javax.servlet.http.HttpSession

Refers

to the user’s session

request

javax.servlet.http.HttpServletRequest

Refers

to the current request to the page

response

javax.servlet.http.HttpServletResponse

Used

for sending response back to the client.

out

javax.servlet.jsp.JSPWriter

page

java.lang.Object

pageContext

javax.servlet.jsp.PageContext

config

javax.servlet.ServletConfig

exception

java.lang.Throwable

 

(6)
VIEW MORE
Please fill in a comment to justify your rating for this review.
Post

Recommended Top Articles

Question & Answer