Surprised that this two works:
B.<jsp:usebean id="fruit" type ="String"/>
C.<jsp:usebean id="fruit" type ="String" beanName="Fruit"/>
I thought that for type and class it has to be fully qualified name.
In my tomcat it works for String in type attribute and not in class attribute. But for custom object from custom package it does not work, you have to provide full class name.
My guess is this is because java.lang package is imported by default.
Joined: May 12, 2008
Is it?? that you have use fully qualified class name for class and type attribute even if you use the <@ page import=""> directive to import the required package??
Joined: Feb 09, 2009
For type attribute it works:
<%@page import="si.test.*" %>
<jsp:useBean id="dog1" type="Dog" scope="session"></jsp:useBean>
For class attribute above does not work even with import.
jsp 2.0 spec says:
- class attribute
The fully qualiﬁed name of the class that deﬁnes the
implementation of the object. The class name is case
sensitive. If the class and beanName attributes are not speciﬁed the object must be present in the given scope.
- type attribute
If speciﬁed, it deﬁnes the type of the scripting variable
This allows the type of the scripting variable to be distinct
from, but related to, the type of the implementation class
The type is required to be either the class itself, a superclass
of the class, or an interface implemented by the class
The object referenced is required to be of this type,
otherwise a java.lang.ClassCastException shall occur at
request time when the assignment of the object referenced
to the scripting variable is attempted.
If unspeciﬁed, the value is the same as the value of the class
Joined: May 12, 2008
could you please help me to read API in correct way. I mean where I find the JSP spec that describe the requirments of using JSP standard action and so???
I have the API but i dont know where to find the related details like if I want to know about the required attributes of a particular directive or action tag OR what kind of value they can accept etc...??