Forums Register Login

How to use variables in a javascript from the same JSP

+Pie Number of slices to send: Send
I have got a JSP . On the top of the page I have got a javascript code. Now a variable is declared in the Javascript code, I want to use that variable in my JSP.
How do I do that please help !!!
+Pie Number of slices to send: Send
What's important to understand is that Javascript is interpreted on a different machine than your JSP code, at a different time.
Since Javascript is the result of your JSP's execution, it can only be interpreted (in the browser) after the JSP execution has finished.
+Pie Number of slices to send: Send
Please read this article to understand how JSP works.
+Pie Number of slices to send: Send
temporary workaround for this can be as follows

you can try putting textbox in your jsp and then set the value of the variable to that textbox and then you can access that value once jsp is processed.

but thats true that you can access javascript variable directly in the same JSP
+Pie Number of slices to send: Send
 

Originally posted by Prafulla N. Patil:
temporary workaround for this can be as follows



There really isn't a workaround for not understanding this fundamental web programming concept. I think the original poster will do much better if (s)he stops and takes the time to understand this. Handing him/her a workaround or patch that gets something working without the need for this understanding will hurt more than help.
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this 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 1225 times.
Similar Threads
redirect to another page (not the beggining)
How to access javascript variable of one file in another jsp file
2 Quick simple JavaScript Qu's. Plz Help
JavaScript varialble in a Servlet
How to refer a java variable in javascript code.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:24:02.