Search code examples
javascriptjspstrutsscriptlet

How to get bean values in jsp scriplets and store in a javascript variable?


<bean:write name="<%=(String) currentItr.next()%>" property="<%=(String) currentItr.next()%>"/>

The above code prints the values aka : Nicholas...$100000...45....Actor

How can i assgin Nicholas to a javascript variable?

I tried

var audition = <%=(String) currentItr.next()%>.<%=(String) currentItr.next()%>;

and it prints out the column header like so : Name...Salary...Age...Occupation

what am i doing wrong?


Solution

  • You should try this , if you are assigning string value then use ' ' or " " . For Number value what you wrote was correct .

    var audition = "<%=(String) currentItr.next()%>.<%=(String) currentItr.next()%>";