Forums Register Login

converting variable types

+Pie Number of slices to send: Send
hi..

Im really stuck in here.

I am using both javascript as well as jsp together. I need some way so that i can convert 'var' which is used in javascript to type 'String ' that is used in Jsp.
Is there some way to do this.

thanks,
payal
+Pie Number of slices to send: Send
 

Originally posted by payal kapadia:
Im really stuck in here.

I am using both javascript as well as jsp together. I need some way so that i can convert 'var' which is used in javascript to type 'String ' that is used in Jsp.
Is there some way to do this.



Both, javascript and jsp, are different animals.

Ok Whatever.
By the way why do you want to do this?
+Pie Number of slices to send: Send
jsp is compiled and the contents evaluated in the server first and then on the browser, javascript is evaluated.
This means that u could use a jsp variable in javascript. see a basic usage below.



What this also means is that it would be pretty impossible to do it the other way around i.e use a javascript variable as the value of a jsp variable.

ram.
+Pie Number of slices to send: Send
A useful habit to get into when starting out as a web programmer is to always view and debug your javascript/html code by using your browser's "view source" feature. By doing so, you get used to seeing the HTML/Javascript code without the JSP or ASP or PHP tags. This reinforces the concept that HTML/Javascript is the result from the execution of your server side code and that the two never get interpreted at the same time (or in the same place).

To answer your original question: If you need to get values, changed in the client, back up to the server you will need to re-post them in an HTML form.
You can use Javascript to alter the <input..> fields of your form and to submit the form if you like.
[ February 09, 2005: Message edited by: Ben Souther ]
+Pie Number of slices to send: Send
Good suggestion! That's one thing that folks don't really understand too well when starting out. I don't know if that was included in the "Top 10 List" that was on one of these forums not too long ago, but it should be.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Hi,

Yesterday i had seen this question and tried back in home in differently.

1) By pushing values in javascript to cookie and retriving back in jsp
" which the poolish one i did Because cookies in javascript are
different from and jsp ".

2) By putting the java script value to the hidden filed and pushing back the
to server and assigning the value"


After pushing the values
String val = <%= request.getParameter("hide") %>
// Hidden textfield Value
<% request.setAttribute("jspvalue", val) %> // JSP Value

Error:val does not Contail " quotes in line <% request.setAttribute("jspvalue", val) %>"
3) At last i tried to push the values in a temperory file and get it backto the jsp
Well THAT's new! Comfort me, reliable 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 2399 times.
Similar Threads
how to pass parameter from dispatchto javascript
Form Submission on drop down onchange event
Moving javascript with scriptlets to a separate file
Date - calulate new to x number of months?
disabling fields from drop down menu
Thread Boost feature
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:21:47.