• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to declare and use variables in JSTL ?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,
How to declare variables and use it in JSTL as we do in a JSP page.
Example:
String x="test.jsp";
How to declare like this in JSTL or How to use this value of 'x' in JSTL ?
Yours,
Sankar.B
Information Dynamics, Chennai, India
 
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use <c:set> to set a scoped variable and <% pageContext.setAttribute("x", x) %> to convert a scripting variable into a scoped variable.
 
Sankar B
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
For lot of simpler calculations and validations using Javascript we used to declare variables and then do them and use it in Javascript before submitting a form.
Say, int x=2,y=3;x=x+y; and use it in the form as a default value and then we may validate the user input from Javascript and then post the form date using Javascript itself. For these situations, we need to use Java code for declaring and calculations.
How to use the above declared value without making it as a scoped variable ?
Yours,
Sankar.B
 
Shawn Bayern
Author
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry; I don't understand your question.
If you're asking how to get the JSTL expression language to use a scripting variable, the answer is that it's structurally impossible. You must turn it into a scoped attribute.
If you're asking about some more complicated relationship between JavaScript data and its posting to a JSP page, I'm afraid you haven't supplied enough information.
Hope that helps,
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic