• Post Reply Bookmark Topic Watch Topic
  • New Topic

using JSTL variable in java code of JSP

 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
How to use your JSTL variable in java code of JSP ?
suppose <c:set var="foo" value="bar"/>
now I want to declare a variable str which has same value as foo.
i.e what should I write so that str will also contain 'bar' ?
thanks in advance....waiting for replies
-Anand
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to assume that you know that the whole purpose of the JSTL is to allow Java to be removed from the page and that what you are trying to do cannot be achieved with other JSTL tags...
Your <c:set> tag will place the value as an attribute in the page context. You can retrieve it in Java code and assign it to your scriptlet variable with the appropriate casting.
 
Anand Gondhiya
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!