Get the JavaScript variable into JSP

Do anybody know how to get the variable from JavaScript into JSP's variable?

for example:

<script language="JavaScript">

<!-- Hide

for(i=0;i<10;i++)

{

temp = <%=name.elementAt(i)%> //this JSP's "i" should be equal to the JavaScript's "i"

}

[323 byte] By [tsangboy] at [2007-9-26 1:28:29]
# 1

Hi 1

I am too facing the same probelm but i guess u cant use the java part or jsp scripplets in javascript since jscript is for client sde while javaserverpages r for server side scripting & hence they cant be mingled together...so either pass the value of i in a jscript function & use it accordingly...or try some other method & do let me know of it...

rohit29 at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

<script language="JavaScript">

<!-- Hide

for(i=0;i<10;i++)

{

temp = <%=name.elementAt(i)%> //this JSP's "i" should be equal to the JavaScript's "

Hope "name" is a vector right?

what you do is

define an array variable and assign with this vector values..

Even you can use a String (JavaScript variable )

Generate stings..like s1|s2|..etc

then use split method in String to get array.

sribk at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
can u please make this clearer i couldnt get it ....Do u think that java portion can be included within the javascript functions
rohit29 at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

No you can't include ..

eg..

say that you have a vector

<%

Vector vecNames = new Vector();

vecNames .addElements("rohit29");

vecNames .addElements("rohit30");

vecNames .addElements("rohit31");

vecNames .addElements("rohit32");

int i=0;

String str="";

while (i < vecNames.size()){

str +=vecNames.toString().trim()+"|";

}

%>

<script>

var strString=<%= str %>;

function functionTest(){

var strArray = strString.split("|");

for(i=0;i< strArray.length;i++)

{

alert(strArray);

}

</script>

Hope this is what you needed... ?

sribk at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Just tell me 1 thing that within a java script function can i set a bean variable's value such as <script lang......>stat.setResult(final);</script>something like this...does this work.....
rohit29 at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
No you c'nt do that , I hope!. ;)
sribk at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
because bean resides on Server.. U should use server side script to do this
sribk at 2007-6-29 1:14:21 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...