This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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 Head First Android 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
Author

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
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();
%>


Regards,
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
 
jQuery in Action, 3rd edition
 
subject: importing class file in jsp
 
It's not a secret anymore!