Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JSP and the fly likes importing class file in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "importing class file in jsp" Watch "importing class file in jsp" New topic

importing class file in jsp

Naresh Saw
Ranch Hand

Joined: Sep 03, 2005
Posts: 66
hi all

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

this is not working

<%@ page import="Test" %>

naresh<br />SCJP 1.4(86%), SCWCD 1.4(78%)
pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
This is the way u can import class

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

suppose package name is Suppot
class is smart

<%@ page language="java" import="Support.*"%>
smart a=new smart();

Pankaj Patil
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
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
I agree. Here's the link:
subject: importing class file in jsp
Similar Threads
jxl.jar to be used in a .jsp file
compilation error
Beans and Form processing
J2EE for Beginners
using custom tags & tag handler class - URGENT