On Thu, 24 Jan 2002, Marcelo Demestri wrote:

> Date: Thu, 24 Jan 2002 16:49:00 -0800
> From: Marcelo Demestri <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: Tomcat Users List <[EMAIL PROTECTED]>
> Subject: Re: setting classpath in TOMCAT 4.0
>
>     Hi Craig!
>     Only a curiosity...
>     Proving the execution of beans through a jsp page, I discovered that if
> I directly put my class in "MyApp/WEB-INF/classes" and made the call from
> the jsp page,
>
>         <jsp:useBean id="formbean" class="z.testBean" scope="session" />
>
>     TC gives me this error:
>
>         java.lang.ClassNotFoundException: testBean
>
>     Only after including my class in a package, the call worked. Why?
>     Thanks in advance...
>

For unpackaged classes to work you *must* explicitly import them:

  <%@ page import="testBean" %>
  <jsp:useBean id="formBean class="testBean" scope="session"/>

because otherwise the Java compiler (which takes the generated code for
your page and turns it into a Java class) will assume the bean is in the
same package as whatever package Tomcat puts your generated page class
into (which differs among containers, and even among versions of
containers, because it is not defined in the specs).

Bean classes that are explictly packaged don't need this, because you have
already identified the package unambiguously.


>                 Marcelo

Craig


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to