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 <[email protected] 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:
<[email protected] 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:
Output of the Jsp program:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: February 6, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles