File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Tomcat 4.0 and JSP- problem using beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Tomcat 4.0 and JSP- problem using beans" Watch "Tomcat 4.0 and JSP- problem using beans" New topic

Tomcat 4.0 and JSP- problem using beans

Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
OK, I am sorting my way through the minimalist documentation that comes with Tomcat 4.0, the JSP QuickStart Guide ( which refers to Tomcat version 3.0, and the great tutorial at
I have managed to run all the samples that come with Tomcat, I can run the samples that come with the Quickstart guide. I have even managed to follow through and write JSP code, based on the tuotrial at
It is the JSP using Bean class that is giving me grief for almost one whole day.
I am using JDK 1.3.1, Tomcat 4.0.1 on a windows NT 4 PC.
I was running all the examples from the by placing them under the
tomcat_home/webapps/root folder , without any problem.
I created a bean class and placed the .java and the .class files under
tomcat_home/webapps/root/web_inf/classess folder,
but the compiler does not see the class.
Here is the error I get
Class org.apache.jsp.UserData not found.
After looking at the example from Sun's Quickstart, I changed the directory structure so that the .jsp and .html files are under
tomcat_home/webapps/mytutorial folder and the .java and .class files for the bean class are under tomcat_home/webapps/mytutorial/web-inf/classes folder. No luck still. In fact I am not even able to bring up the html file. I get the famous 404 error.
So my questions are :
How can I set up another folder under tomcat_home/webapps to contain all the code I am writing?
Where should I place the bean class files so that the JSP compiler can see them ? I saw in some examples that included an applet, they had used the "codebase" attribute. Do I have to use something similar with bean classes as well?

Jason Brawner
Ranch Hand

Joined: Dec 19, 2001
Posts: 66
Beans have to be in a package and the JSP's need to import that package. Place the package under the classes directory like \classes\mypackage\.
Then use the following to import the package:
<%@ import="mypackage.*" %>
Hope this helps,

Jason E. Brawner<br />Sun Certified Java Programmer<br />Sun Certified Web Component Developer
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
Jason :
I tried that :
I recompiled the source file with a
package mypackage; statement and then copied the class file to tomcat_home\webapps\ROOT\WEB-INF\classes\mypackage folder
and I have the following import statement in my jsp file

<%@ page import="mypackage.*" %>

But I still get the error
"Class org.apache.jsp.UserData not found.". Why is the compiler looking for org.apache.jsp package structure?
Also how can I get this code to work under some other folder in the webapps folder ?
Hari Haran

Joined: Sep 21, 2000
Posts: 19
I also had the same problem.
But I had a workaround and placed the classes under $CATALINA_HOME/common/classes.
Now it is working fine.
But I still dont understand why it doesnt work if I put in my application folder like
/WEB-INF/classes of your web application
If anybody can find a solution it.

But according to Tomcat documentation this is what they had to say:
Therefore, from the perspective of a web application, class or resource loading looks in the following repositories, in this order:
/WEB-INF/classes of your web application
/WEB-INF/lib/*.jar of your web application
Bootstrap classes of your JVM
System class loader classses (described above)
I agree. Here's the link:
subject: Tomcat 4.0 and JSP- problem using beans
It's not a secret anymore!