This tutorial contains description of import attribute of page Directive.
import Attribute :
This attribute of page directive imports single package and classes or list of packages and classes . For multiple import you can use comma(,) for separation. By default, jsp container automatically imports java.lang.*, javax.servlet.*, javax.servlet.jsp.*, and javax.servlet.http.*.
Syntax :
<%@ page import="java.sql.*,java.util.*" %>
Example :
importAttribute.jsp -
<%@page import="roseindia.ImportExample"%> <html> <head> <title>Import Attribute</title> </head> <body> <font size="10" color="orange" style="border-bottom-style: dashed;"> <% ImportExample ex = new ImportExample(); out.print(ex.display()); %> </font> </body> </html>
ImportExample.java -
package roseindia;
public class ImportExample {
public String display() {
return "Hello Roseindia";
}
}
Output :