Monday 27 May 2013

JSP directives

Tags

What are JSP directives?
  • JSP directives are messages for the JSP engine. i.e., JSP directives serve as a message from a JSP page to the JSP container and control the processing of the entire page
  • They are used to set global values such as a class declaration, method implementation, output content type, etc.
  • They do not produce any output to the client.
  • Directives are always enclosed within <%@ ….. %> tag.
  • Ex: page directive, include directive, etc.
11.What is page directive?
  • A page directive is to inform the JSP engine about the headers or facilities that page should get from the environment.
  • Typically, the page directive is found at the top of almost all of our JSP pages.
  • There can be any number of page directives within a JSP page (although the attribute – value pair must be unique).
  • The syntax of the include directive is: <%@ page attribute="value">
  • Example:<%@ include file="header.jsp" %>


12.What are the attributes of page directive?
There are thirteen attributes defined for a page directive of which the important attributes are as follows:
  • import: It specifies the packages that are to be imported.
  • session: It specifies whether a session data is available to the JSP page.
  • contentType: It allows a user to set the content-type for a page.
  • isELIgnored: It specifies whether the EL expressions are ignored when a JSP is translated to a servlet.


13.What is the include directive?
There are thirteen attributes defined for a page directive of which the important attributes are as follows:
  • The include directive is used to statically insert the contents of a resource into the current JSP.
  • This enables a user to reuse the code without duplicating it, and includes the contents of the specified file at the translation time.
  • The syntax of the include directive is as follows:
  • <%@ include file = "FileName" %>
  • This directive has only one attribute called file that specifies the name of the file to be included.


EmoticonEmoticon