Advanced Java (2160707)

BE | Semester-4   Winter-2018 | 20-11-2018

Q3) (b)

Explain any two page directive in JSP with example.

Page Directive

  • The page directive defines attributes that apply to an entire JSP page.
  • You may code page directives anywhere in your JSP page.
  • By convention, page directives are coded at the top of the JSP page.
  • Syntax : <%@page attribute="value" %>

Attributes of JSP page directive

  1. import
    • Used to import class, interface or all the members of a package
    • Example : <%@ page import="java.util.Date" %> Today is: <%= new Date() %>
  2. contentType
    • The contentType attribute defines the MIME type of the HTTP response. The default value is "text/html;charset=ISO-8859-1"
    • Example : <%@ page contentType=application/msword %>