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:
Output of the Jsp program:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.