aspose file tools*
The moose likes JSP and the fly likes Bean Importing error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Bean Importing error" Watch "Bean Importing error" New topic
Author

Bean Importing error

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
When I am using trying to use a bean in my jsp files I get an error unless I put in the entire class path (in the useBean tag). I have my class in WEB-INF/classes/some/thing/database/ConnectorBean.class
<jsp irective.page import="some.thing.database.*" info="Bean Tester Page" contentType="text/html;charset=ISO-8859-1"/>
<HTML>
<BODY>
<!-- Test Dbconnector Bean -->
<jsp:useBean id="dbconnector" class="some.thing.database.ConnectorBean" scope="application" />
Like I said it works fine unless I take out the full class path (which should not be required). I made a .jar file, which resides in the WEB-INF/lib/ folder. Does this need to be in the $CLASSPATH variable? Any help would be greatly appreciated.
[ November 18, 2003: Message edited by: Kerry Wilson ]

http://www.goodercode.com
SCJP 1.4
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

When I am using trying to use a bean in my jsp files I get an error unless I put in the entire class path

What makes you think you can get away without specifying the full name of the class?
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tim Baker
Ranch Hand

Joined: Oct 04, 2003
Posts: 541
Originally posted by Bear Bibeault:

What makes you think you can get away without specifying the full name of the class?
bear

his import statement i presume


Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

The import statement is immaterial. Although the means of instantiation is left up to the container, most servlet containers will use Class.forName() (or something that eventually calls forName() such as java.beans.Beans.instantiate()) which require a full class name to operate.
Resin, interestingly enough, is the only container I tested that does a direct "new" operation, and hence is sensitive to the import.
Bottom line is, specify the full class name.
bear
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

That's the operative word, BTW, it's fully-qaulified class name, not class path, which is a thing 'nother entirely.


Customer surveys are for companies who didn't pay proper attention to begin with.
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
So if I am going to need to put the fully qualified class name in every usebean tag what good is the import statement?
[ November 19, 2003: Message edited by: Kerry Wilson ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

The import statement will apply to any Java scriplets that you write in the JSP. <normal disclaimer about accepted best practice is to limit scriplets>
bear
Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
Understood, thanks alot.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bean Importing error