JSP Directive

In JSP (JavaServer Pages), there are two types of directives: page directives and include directives.

Page Directive 

The page directive is used to provide instructions to the container about how to translate and execute the JSP page. It is typically placed at the top of the JSP page and enclosed within <%@ and %> tags.

 Example

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

    pageEncoding="ISO-8859-1"%>

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

Here are some commonly used attributes of the page directive:

language - Specifies the programming language used in the JSP page (default is Java).

contentType - Specifies the MIMEMultipurpose Internet Mail Extension) type and character encoding of the response.

import - Specifies a list of Java classes or packages to be imported.

session - Specifies whether to enable or disable session tracking for the JSP page.

errorPage - Specifies the URL of the error page to be displayed if an exception occurs.


Include Directive

 The include directive is used to include the contents of another file in the current JSP page. It is typically used to reuse common page elements such as headers, footers, and navigation menus. 

The included file must be a valid JSP page or HTML file.

The path to the included file can be absolute or relative to the current JSP page.

The included file can also contain other include directives, allowing you to chain multiple files together.





 

 

No comments:

Post a Comment