Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bean Importing error

 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the operative word, BTW, it's fully-qaulified class name, not class path, which is a thing 'nother entirely.
 
Kerry Wilson
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understood, thanks alot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic