[an error occurred while processing this directive]

The import Attribute of page Directive In JSP


This section shows you how to import a java package or the class in your jsp application. Here a Java code has also been provided which class has been imported in the following JSP code like <%@page import="roseindia.Extends" %> in which, the import is the attribute of the page directive in JSP and the value of the attribute is the "roseindia.Extends". Here, roseindia is the package name and the Extends is the class which is made after compilation of the Extends.java file. This class file is contained by the folder which determines the package name. And the package name folder is putted in the classes folder inside the <your application root directory>/WEB-INF/classes/package_name.

Basically, this attribute of the page directive imports the java packages and it's classes more and more. You can import more than one java packages and classes by separating with comma (,). You can set the name of the class with the package name directly like packagename.classname or import all classes of the package by using packagename.*.

Here is the code of the program:

<%@page import="roseindia.Extends" %>
  <head><title>Example of Extends 
Attribute of page Directive in JSP</title></head>
    <font size="20" color="red">
	Extends ex = new Extends();
Here is the code of Extends.java file:
package roseindia;

public class Extends{
  public String show(){
    return "Roseindia.net";
Output of the Jsp program:

Download this JSP example.


[an error occurred while processing this directive]