On Jun 17, 2008, at 12:42 PM, Hacking Bear wrote:

See in the discussion link


You need to address the section I quoted from the spec. It is extremely clear:

> 5. If the object is not found in the specified scope and neither class nor beanName are > give, a java.lang.InstantiationException shall occur. This completes the processing of this
> jsp:useBean action.

There is zero ambiguity in that rule.

>>>>

However, you may be right that the tag lib spec allows the use of type attribute only. In http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html , it first says "If the Bean does not exist, <jsp:useBean> instantiates it from a class or serialized template." and then on the attribute description:


That page is not part of the spec.  Also, it appears to be for JSP 1.1.

>>>>

Here are some relevant snippets from the JSP 2.1 spec. However, as far as I know the sections haven't changed for either 2.0 or 2.1 versions:
(section JSP 5.1, <jsp:useBean>)
It is also possible to use this action to give a local name to an object defined elsewhere, as in another JSP page or in a servlet. This can be done by using the type attribute and not providing class or beanName attributes.

You're quoting from non-normative explanatory/example text. The language is looser. The "Semantics" section is the precisely defined, normative section of the spec.
In the final example, the object should have been present in the session. If so, it is given the local name wombat with WombatType. A ClassCastException may be raised if the object is of the wrong class, and an InstantiationException may be raised if the object is not defined.


That doesn't contradict rule #5 at all. It says an InstantiationException will be raised if the object isn't defined. (And since it's from explanatory text, the language is looser than the language in the Semantics section, i.e. the correct word is "shall", not "may".)


<jsp:useBean id="wombat" type="my.WombatType" scope="session"/>

<<<<

And for all practical purposes, useBean should allow setting the variable to null because many classes are "bean-like" and not strict JavaBean and it is also harder to tell if it is an valid bean or an "empty" bean.

"Should" has nothing to do with specifications. There is only "does" and "does not". There is no "should". (Well, ignoring optional, but highly recommended sections of a spec, which doesn't apply in this case.)

-- Scott



On Tue, Jun 17, 2008 at 12:09 PM, Scott Ferguson <[EMAIL PROTECTED]> wrote:

On Jun 17, 2008, at 11:51 AM, Hacking Bear wrote:

Hi,

As we are discussing some other issues, we found a potential serious problem with jsp:useBean. Basically, if useBean only has the type parameter but not the class/bean parameters, the resin server will fail because it does not know what to instantiate, contrary to the spec.

<!-- should set foo to null but fail instead. -->
<jsp:useBean id="foo" type="java.lang.String" scope="request"/>

How is that contrary to the spec?

JSP.5.1

> 5. If the object is not found in the specified scope and neither class or beanName > are given, a java.lang.InstantiationException shall occur. This completes the
> processing of thisjsp:useBean action.

-- Scott



For the full discussion of the bug and  the JSP spec, see 
http://www.jetbrains.net/jira/browse/IDEA-18405

The strange thing is that Tomcat behaves the same. So I wonder if this is a bug or a legacy problem for the servers due to confusing descriptions in earlier JSP spec?

Please enlighten me!

Thanks
_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest


_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

_______________________________________________
resin-interest mailing list
resin-interest@caucho.com
http://maillist.caucho.com/mailman/listinfo/resin-interest

Reply via email to