Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:set target without scope attribute?

 
liao Yang
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I just noticed that JSTL <c:set target ...> doesn't allow to specify scope.

Is there a design reason for this?

How to resolve attribute name conflicts in different scopes when using <c:set target ...>, e.g. request and session both have a attribute with the same name, but you want to change the one in session scope?

I think we can't do this with <c:set target ...>. The solutions are to use <jsp:setProperty> or <c:set var ...>, right?

Thanks
 
Matthias De Scheerder
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the <c:set target... /> version of the c:set tag, you need to pass in something that actually resolves to a bean.

Say you have two beans named "person" on both request and session scope. You will then set a property on them as follows:

request scope:
<c:set target="${requestScope.person}" ... />

session scope:
<c:set target="${sessionScope.person}" ... />
 
Kathiresan Chinna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

If we don't specify the scope in target expression,
ex:-
<c:set target="${person}" ... />

then this will find from page, request, session, application.

Is right ?

Thanks
Kathir
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic