• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

c:out,c:set

 
amarkirt saroay
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please clarify:

1)If
<cut value='${user}'/>
Here what is the scope in which the container finds user? Does it use findAtttribute() to check in page scope first then request,session and then application?
or how?
2)<c:set var="${user}" value="pink" scope="session"/>

This will look for the variable 'only' in the session scope,if there is an attribute by name'user' it will fetch its value .


Without specifying scope:
<c:set var="${user}" value="pink" />
Now does it by default check 'user' in all scopes? If it does not find in page scope,are the rest of the scopes checked?

<c:set var="${user} value="" />
Now will it remove the attribute from all the scopes? or only from the scope in which it first encounters this variable?

<c:remove var="user" />
This will remove user from all the scopes.
whereas <c:remove var="user" scope="request"/>
This will remove user from only request scope.

Please validate these cases if my understanding is wrong.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Yes all cases are right. The order of search is page,request,session,application..
 
Katrin Perry
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Just a quick correction on 2)

<c:set var="${user}" value="pink" scope="session"/>

would cause the following exceptioin:
org.apache.jasper.JasperException: /Test.jsp(33,0) According to TLD or attribute directive in tag file, attribute var does not accept any expressions

The reason it that var attribute is declared with: <rtexprvalue>false</rtexprvalue>
and it doesn't accept scripting expressions or EL expressions.

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