aspose file tools*
The moose likes JSP and the fly likes JSP can't find bean classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP can Watch "JSP can New topic

JSP can't find bean classes

Richard Scothern
Ranch Hand

Joined: May 25, 2001
Posts: 83
I'm running Tomcat 3.2.3 on Windows 2000. I've been working with servlets and JSP and so far everything has been working fine.
I've just started using JavaBeans in my JSP pages, but whenever I run them I get an internal servlet error with the message: Can't find class xxxbean.
Here is my classpath and directory information:
JSP files directory:
Bean object:

In my JSP file I am using the line:
<jsp:useBean id="stringBean" class="beans.StringBean" />
But it claims not to be able to load the class StringBean.
Any help appreciated.
raymond yadao
Ranch Hand

Joined: Jan 29, 2001
Posts: 88
you must import the the bean(the folder where you put your beans). put this code:
<%@page import="beans.*" %>
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Your jsp and the bean class have to be under the same webapp.
It looks like your jsp is under a jsp webapp and your bean is under the ROOT webapp.
| |
| |-jspwork
| | (Here be your JSP files)
| |
| |
| | |-classes
| | |
| | |-beans
| | | (here be your classes)
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Stone Golem

Joined: Oct 27, 2001
Posts: 8
A. Make sure your java classes are public. <-- obvious, yes, but it's one of those mistakes that will drive you to sell your computer.
B. Use packages. In the first line of code in your classes add 'package myPackage;'. Then put all your beans in on directory. In your useBean tag, use 'class="myPackage.yourClass"',
C. Make sure your CLASSPATH is set properly. Your CLASSPATH is similar to PATH, but it points to the directory of your .class files.
After you do this, and you consider the other replies, you should be good to go.
Stone Golem
Ranch Hand

Joined: Oct 30, 2000
Posts: 94
what is ROOT in the directory path of ur bean??
the path for jsp file should be
for beans it should be
What if this is as good as it gets ?
Dave Jilson

Joined: Feb 24, 2004
Posts: 1
Is there a way to use static methods from a class that isn't in a package?
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61220

The containers' classloaders have problems with packageless classes. Best to put your classes in a package regardless of whether you will be accessing them through static references or not.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: JSP can't find bean classes