Forums Register Login

How to declare and use variables in JSTL ?

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
You can use <c:set> to set a scoped variable and <% pageContext.setAttribute("x", x) %> to convert a scripting variable into a scoped variable.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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,
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 5120 times.
Similar Threads
How to pass values between JSP - JSTL - Javascript ?
scripting variables
Displaying contents of arraylist in jsp
JSTL and EL
Array Conversion Help
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:53:38.