It's not a secret anymore!*
The moose likes JSP and the fly likes How to pass value from Java to JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

How to pass value from Java to JavaScript

Ruta Kulkarni
Greenhorn

Joined: Dec 24, 2010
Posts: 1
I would like to know is it possible to pass value from Java to JavaScript.

I have called REST Web service which will return me the JSON Array response in Java, I want to pass this response to JavaScript. I can parse the response form JavaScript and can display it from HTML.

Please let me know if there is any possible way for it.

Thanks in advance.



Kishore Tulsiani
Greenhorn

Joined: Jan 15, 2010
Posts: 21
what I can say is from java you can store the value in request and from request you can take that value and store it in hidden element on HTML. once you got the value in hidden element it can be easily accessible in java script

sample code

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60756
    
  65

Not directly. This question has been asked many times and has an entry n the JspFaq.

Please SearchFirst.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to pass value from Java to JavaScript
 
Similar Threads
Javascript variable inside jsp scriplet
passing value from javascript function to JSP
assign var to java variable
Applet to Javascript communication
Passing value to JSP from a method in Action class