Hi there everyone, I am still having a problem with using a simple javabean in my jsp page. I'll put the error message at the bottom of this post. Its essentially saying that the class for the mean can't be found. Here's some additional info that I am desperately hoping will help: The bean is located in the WEB-INF/classes directory and as such has no package name (i think thats right) I try and import the bean using: <jsp:useBean id="counter" class="CounterBean"/> Now, I use netbeans to compile the javabean and I have a slight feeling that it may be screwing something up. I have already asked roughly this question a good few days ago, and someone said that the compiler is thinking that my classes directory is part of the package. I don't know why he thinks that, but does anyone else concur or have any suggestions. This is so sill. I just want to do something incredibly basic! Thanks to anyone who can offer some assistance Kind Regards Simon
Amol is exactly right. If you don't put ALL classes used in servlets in a package you get hard-to-understand exceptions like that. It has to do with the way classes are located if they don't live in a package. Furthermore you will want to include an import attribute in a page directive or use the complete package.class name in your code. Bill
You can't import a packageless class (such as your JavaBean) into a packaged class (such as your JSP). I learned this the hard way...
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Joined: Jan 26, 2003
Thanks everyone, I'm a bit dubious though because the reason I put the bean in a packageless class is to make it as simple as possible - it wasn't working when I did have it in a package either. Just so I know what I'm doing, do I put a folder in ...\classes eg \classes\my_package and then in the javabean, my code will have package my_package at the very top. I'll give that a try in a second. I really hope this works! Thanks again everyone. Thats a big help Simon
Joined: Jun 06, 2002
That's correct. Then in your JSP, refer to it by its full name -- myPackage.CounterBean.