• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification required -HFSJ page 447

 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Twon thing I'd like to point out in this page which I don't think is correct:

1.> In the "Key points and gotchas" column the last point says:
If the target expression is a bean, but the bean does not have a property that matches "property", the Container throws an exception. But be careful, because the EL expression by itself will NOT cause an exception to be thrown if the property doesn't exist. So even though : ${fooBean.notAProperty} won't cause an exception by itself(it just returns null), if that same "notAProperty" is the value of a "target" attribute, the Container throws an exception.


This is NOT TRUE...if you use ${fooBean.notAProperty} and the property "notAProperty" is not a property of this bean, the container throws an ELException.

2.>Just beside this column, in the Q & A section, the second one reads:
Q: If I don't specify a scope, does that mean it will find attributes that are ONLY within page scope, or does it do a search beginning with page scope?
A: If you don't use the optional "scope" attribute in the tag, and you're using "var", the container will search scopes in the order in which you've come to expect--page, then request, then session, then application(context).
If you use the var version without a scope, and the Container can't find an attribute of that name in any of the 4 scopes, the Container makes a new one in page scope.


What exactly is implied here? Did they mean that if the Container finds an attribute of that name in any of the 4 scopes( say application scope) then it's replaced by this one in that scope.....or is it meant that if an attribute is found in any of the four scopes then the new value is not set?

Well, both don't hold good....If you don't specify a "scope", the Container sets the new attribute in the page scope...I've tried it out and that's what I've got.


Could anybody please confirm this.....it would be very helpful....
Many thanks in advance.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reply for your first point.

Sayak, you and the book says the same. Read it again clearly.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your second point.

You are right, Sayak. Its really a good piece of information.

<c:set var="avar" value="Preparing for SCWCD" scope="session"/>
<c:set var="avar" value="My Name is sreeraj"/>
${pageScope.avar}<br>
${sessionScope.avar}<br>


it displays

My Name is sreeraj
Preparing for SCWCD
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first point says if you use a non-existent bean property in an EL expression, it does not throw an Exception(please check the part of the sentence in bold)....but that is NOT TRUE....that too throws an ELException



Try this code...you'll get an ELException
[ December 22, 2006: Message edited by: Sayak Banerjee ]
 
Ali Gohar
Ranch Hand
Posts: 572
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes i can also see javax.servlet.jsp.el.ELException exception while trying to access a property of bean which doesn't exist.

So i think that which is written in the book is invalid. BTW i don't have HFS&J book
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply....that's why I mentioned everything here...you won't need the book
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic