Share on Google+Share on Google+

Page Directive attribute - import

Advertisement
This tutorial contains description of import attribute of page Directive.

Page Directive attribute - import

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 :

Advertisements

Advertisement

Posted on: November 29, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.