OK, I am sorting my way through the minimalist documentation that comes with Tomcat 4.0, the JSP QuickStart Guide (http://java.sun.com/products/jsp/html/jsptut.html)- which refers to Tomcat version 3.0, and the great tutorial at jsptut.com. 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 jsptut.com. 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 JSPTUT.com 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?
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
Joined: Jan 11, 2002
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 ? Thanks
Hi, 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 pls.post 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) $CATALINA_HOME/common/classes $CATALINA_HOME/common/lib/*.jar $CATALINA_HOME/classes $CATALINA_HOME/lib/*.jar "