method for passing java variable value to jstl in jsp page -


i found out code pass java variable jstl :-

<% string str = "abc"; pagecontext.setattribute("str", str); %> 

and value in jstl tags have use code :-

<c:out value="${str}"/> 

my main question that, if there other method pass on values, java jstl?

it looks pagecontext, request attributes, session attributes, application context variable resolution, can put value in of

in example putting in pagecontext

from our el wiki

${str} 

does same following in "raw" scriptlet code (the below example simplicity, in reality reflection api used obtain methods , invoke them):

where pagecontext#findattribute() scans attributes of respectively pagecontext (page scope), httpservletrequest (request scope), httpsession (session scope) , servletcontext (application scope) until first non-null value found. please note doesn't print "null" when value null nor throws nullpointerexception unlike when using scriptlets. in other words, el null-safe.


Comments