Doubt from the JSP Spec

Reema Patel

Ranch Hand

Posts: 169

posted 10 years ago

Hello All, I'm going through JSP Spec 2.0. I'm not able to comprehend the meaning of the following text taken from the "Standard Actions" section, it's on using JavaBeans from inside JSP pages and about the scopes where a bean can be stored or retrieved.

It is Illegal to change the value of an instance object so associated, such that its new runtime type is a subset of the type(s) of the object previously so associated.

Can anyone help here?

Scheepers de Bruin

Ranch Hand

Posts: 99

posted 10 years ago

It's a bit difficult out of context...

Could you post a bit more, just to understand all that is referred to?

We're doomed!!<br />Yay!!!<br />No that's bad Girr!!<br />Yay!!!

Stefan Evans

Bartender

Posts: 1836

10

posted 10 years ago

I think he is referring to section JSP5.1 on the <jsp:useBean> tag, specifically the discussion of the "scope" attribute.

The scope Attribute The scope=�page|request|session|application� attribute/value tuple is associated with, and modifies the behavior of the id attribute described above (it has both translation time and client request processing time semantics). In particular it describes the namespace, the implicit lifecycle of the object reference associated with the name, and the APIs used to access this association. For all scopes, it is illegal to change the instance object so associated, such that its new runtime type is a subset of the type(s) of the object previously so associated. See Section JSP.1.8.2 for details on the available scopes.

I think it is saying once you have declared a bean with the useBean tag, you shouldn't go and change the underlying attribute to be a class that is not compatible. For instance the following (stupid) code would be illegal.

[ October 09, 2006: Message edited by: Stefan Evans ]

Reema Patel

Ranch Hand

Posts: 169

posted 10 years ago

I'm posting a fragment from the "application" scope. [the text in bold is common for all four scopes]

application The named object is available from the current page�s ServletContext object using the getAttribute(name) method. This reference shall be discarded upon reclamation of the ServletContext. It is Illegal to change the value of an instance object so associated, such that its new runtime type is a subset of the type(s) of the object previously so associated.