tags:

views:

15

answers:

1

Hi

Currently I am trying to send JSP value to javascript. Is it possible? My cases is as follows:

On Page abc.jsp, user enters data in form. Which is send on the next page xyz.jsp. I want to use this data in xyz.jsp pages javascript. Is it possible? Is yes how to do this?

also would like to know, if I auto refresh this page(or part of page) ie xyz.jsp then is it possible without javascript failing or crashing?

Thanks.

A: 

Just let JSP print it as if it is a JS variable. Assuming that you've variable ${foo} in JSP:

<script>var foo = '${foo}';</script>

This will end up in webbrowser as

<script>var foo = 'somevalue';</script>

Keep in mind: JSP runs at webserver and produces HTML. JS is part of HTML and runs at webbrowser.

See also:

BalusC
Thanks Balus. That helped. :)
You're welcome.
BalusC