Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp The import Attribute of page Directive In JSP

Related Tutorials


 
 

Share on Google+Share on Google+

The import Attribute of page Directive In JSP

Advertisement
This section shows you how to import a java package or the class in your jsp application.

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" %>
<html>
  <head><title>Example of Extends 
Attribute of page Directive in JSP</title></head>
	
   <body>
    <font size="20" color="red">
     <%
	Extends ex = new Extends();
	out.print(ex.show());
     %>
    </font>
   </body>
</html>
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.

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  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.

Posted on: February 6, 2008

Related Tutorials

Discuss: The import Attribute of page Directive In JSP   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com