File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes doubt from jsp:setProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "doubt from jsp:setProperty" Watch "doubt from jsp:setProperty" New topic

doubt from jsp:setProperty

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The object named by the name must have been “introduced” to the JSP
processor using either the jsp:useBean action or a custom action with an
associated VariableInfo entry for this name.
Note: a consequence of the previous paragraph is that objects that are stored
in, say, the session by a front component are not automatically visible to jsp:set-
Property and jsp:getProperty actions in that page unless a jsp:useBean action, or
some other action, makes them visible.

what does the above mean ..anyone with a simple example
Michael Yuan
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Where does the above text come from? I could store a bean as an attribute in PageContext and then access it using <jsp:getProperty> tag later. No <jsp:useBean> or VariableInfo involved ...
It works on Tomcat 4.0 at least ...

Seam Framework:
Michael Yuan
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
OK, I guess Tomcat does not exactly conform to the specification. I run my above mentioned code in resin and it would not run.
I think jsp:useBean does two things:
1. Put the bean instance into PageContext with ID attribute and the given scope;
2. Export the bean instance to a script variable with the name given in ID attribute.
If you want to write your own useBean tag, you need to do both. The first is quite easy. You can export the script variable using <variable> element in the tag's tld.
I agree. Here's the link:
subject: doubt from jsp:setProperty
It's not a secret anymore!