• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF Servlets and JSP page 445

 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the top of page 445 it says "What if you simply want to create a new request scoped attribute." It seems to imply you can't do that with standard actions. But doesn't the jsp:usebean create a request scoped attribute (when the jsp:usebean tag's scope attribute is set to "request")?
 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm totally confused by page 445 - 447. At the top of page 445:

Set comes in two flavors: var and target. The var version is for setting attribute variables, the target version is for setting bean properties or Map values.


But isn't a bean or a Map an "attribute variable", or do I not understand the term "attribute variable"?

Then at the bottom of page 446:

The "target" must evaluate to the OBJECT! You don't type in the String "id" name of the bean or map attribute.


What the heck does this mean?
 
Roger Yates
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wally,

I think your understanding is ok. For simple attribute variables e.g. "myAttr"="Fish" you could use the var version of set.
For more complex attributes such as beans or maps where you can't just say "person="Fred, 18 years, 12, a road, somewhere" you have to use c:set target=. Then you can specify which property of the target you want to set (e.g. name, address, age etc.)

Where it says target must evaluate to the object it means that you must use an EL expression (${}) or script expression (<%= %> that evaluates to the object.
e.g. if you would access the attribute using <jsp:useBean id="myPerson" ....>, you can't just access it with c:set target="myPerson". Instead you must access it using c:set target=${"myPerson"} or <%="myPerson">.

I'm guessing it makes it easier for the container's generated code this way!

HTH
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic