JSP directives - What are JSP directives?

Define JSP directives.

-The page directive
-The include directive
-The taglib directive

Page directive:

The page directive allows to apply different attributes that is to be added to a JSP. These attributes gives special processing information to the JSP engine which allows the way of processing JSP pages. The following are the various page directives that are used in JSP.

•language
•extends
•import
•session
•buffer
•autoFlush
•isThreadSafe
•info
•errorPage
•IsErrorPage
•contentType

The syntax of any page directive is : <% @page optional parameters …..> , where optional parameters can be any one of the above directives.

Include directive:

The include directive is used to insert a static file which will parse the JSP elements. The syntax is : <% @include file = jsp file %>

Example:
<% @include file=login.jsp %>

The include file can be a static file such as HTML or a dynamic page such as JSP file. If the file is a JSP page , the JSP elements are parsed and their results are included in the current JSP page.

Tag Libraries:

JSP technology supports the development of reusable components called custom actions. A custom action is invoked by the custom tag. A tag library is a set of custom tags. Examples are form processing, accessing databases and other enterprise services such as email , flow controls etc. JSP tag libraries are used for web developers who are focused on presenting the issues.

The following are the some of the features of JSP custom tags:

•The custom tags can be customized through passing the attributes from the calling page.
•They can be accessed by all the available objects of JSP page.
•The response of the generated page can be modified by custom tags by calling the page.
•They can create and initialize a java bean component in order to communicate each other.
•Complex interaction can be done with JSP page by nesting the custom tags..

What are JSP directives?

AnswerJSP directives are used to set global values like class declaration, content type etc. have scope for entire JSP file. There are 3 directives that can be used in JSP.

Page directive
Page directive is used to define page attributes.

Include directive
This directive is used to include content of the file in the current .jsp page.

Taglib directive
Taglib, JSP tag extension, provides a way of encapsulating reusable functionality on JSP page.

Explain the types of JSP directives.

There are three directives in JSP. They are

• Page directive
• Include directive
• Taglib directive

All the page directives begin with <% @ and end with %>

Page Directive:

Page directive specifies the instructions which applies to the entire source file , to the JSP engine.

Example :
<%@ page language="java" import="java.util.*>


Include Directive:

Include Directive includes a static web page in a JSP file.

Taglib Directive:

Taglib Directive permits a page to be used as a custom tag and also defined the tag library.

Example:
<%@ taglib uri=”uritaglibrary” prefix=”tagprefix” %>
JSP implicit objects - What are different implicit objects of JSP?
JSP implicit objects - There different implicit objects of JSP are pageContext,pageScope,requestScope...
What are scopes an object can have in JSP page?
JSP object - An object can have following scopes in a JSP page: Page Scope,Request Scope, Session Scope...
Explain why and how to disable session in a JSP page.
JSP Session - Disabling the session improves the performance of a JSP container. When a JSP is requested, an HttpSession object...
Post your comment