0

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.

0

1 Answer 1

1

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:

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.