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.
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?
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.
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 ]
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.
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
Post by:autobot
Well THAT's new! Comfort me, reliable tiny ad:
a bit of art, as a gift, that will fit in a stocking