tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Суржин Константин Вадимович <>
Subject RE: jsp to servlet
Date Wed, 28 Oct 2015 08:27:31 GMT
>You are asking for a bean with the class name "Animal", and the JSP compiler and/or runtime
>can't find it. I'm guessing you meant to use "org.animal.Animal" here?

<jsp:useBean id="animalBean_1" class="org.animal.Animal" scope="session">

JSP  compiler produce next servlet code:
org.animal.Animal animalBean_1 = new org.animal.Animal();

It's OK without  import directive.


<%@page import="org.animal.Animal"%>
<jsp:useBean id="animalBean_1" type="Animal" beanName="org.animal.Animal" scope="session">

JSP  compiler produce next servlet code:
Animal animalBean_1 = (Animal) java.beans.Beans.instantiate(this.getClass().getClassLoader(),

And (ClassLoader) the JSP compiler and/or runtime  can find Animal.class

<%@page import="org.animal.Animal"%>
<jsp:useBean id="animalBean_1" class="Animal" scope="session">

But in this case JSP  compiler produce of different servlet code
Animal animalBean_1  = (Animal) java.beans.Beans.instantiate(this.getClass().getClassLoader(),

The method instantiate(...,...) does not have a fully qualified name of Animal and It's does
not work.

And (ClassLoader) the JSP compiler and/or runtime TomCat or GlassFish can't find Animal class
in /WEB-INF/classes/org/animal/

So, directive <%@page import="org.animal.Animal"%> has no effect here and 
beanName="" or class="" org.animal.Animal" cannot be short.
Only fully qualified class name acceptable.
Maybe it's a bug.

But FAQ writes:
Make sure:

Your bean is packaged in a class.
You have fully qualified your class name (e.g.: ) OR
You have imported your class into your jsp (e.g.:  <%@ page import=""%>

> Or do you have a class, Animal, in the default package?

package org.animal;
public class Animal {...}

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message