Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

importing class file in jsp

 
Naresh Saw
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all

how to import class file in jsp which r not in any package

this is not working

<%@ page import="Test" %>
 
pankaj patil
Ranch Hand
Posts: 98
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the way u can import class
1)

<%@ page language="java" %>
<%! class Find
{
private int c=0;
}%>


2)
suppose package name is Suppot
class is smart
then


<%@ page language="java" import="Support.*"%>
<%
smart a=new smart();
%>
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can import classes based on the following conditions,
1. Your class file must be present in the classpath
2. You cannot import classes that are present in the default package.
3. Your class file can be present in jar file which can be in the lib directory.

Ex 1 - by default WEB-INF/classes directory is in classpath.

Ex-2 - You cannot import a class in a jsp page that is present directly under classes directly.It must be present in some package in classes directory
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic