• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use global variable in JSP (scriptless)

 
jamil lusa
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

for the example below:



the EL above ${userName} refer to the attribute which is added in scope. how am i able to use global variable (member variable) in user=? for example the global variable like below:



how can we refer the global object scriptlessly?

thanks in advanced.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no such thing as a global variable in EL. What you do is setAttribute() from the servlet (or other class) before calling the JSP. If you want it available on all JSP pages, you can put it in a filter that always gets called.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, if the same value is to be used by all users, you can put a "global" variable in application scope.

What you moist certainly do not want to do is to mix the EL and JSTL with scriptlets. That's just a big ol' mess!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic