This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes How to Pass Value from struts Action class to java script Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "How to Pass Value from struts Action class to java script" Watch "How to Pass Value from struts Action class to java script" New topic
Author

How to Pass Value from struts Action class to java script

smitha mulu
Greenhorn

Joined: Aug 18, 2009
Posts: 6
Hi

How can we pass count value from struts action class to java script in jsp .. i want to print the count in javascript pop up

in actions class

request.setAttribute("count",count)

in jsp

<script type="text/javascript">

function noofcount(count){



}

</script>


<input type="submit" value="submit" onlclick="return noofcount(count);">

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Think about what the rendered JavaScript would look like, then write the JSP to create that JavaScript.
Aditya Keyal
Ranch Hand

Joined: Dec 01, 2008
Posts: 71
To replace the value of count with the actual calue in the javascript use the bean:write tag..

ex.



There is only one catch, if count is a number you can keep the above code. If count were a string value.. surround the bean:write with a pair of single quotes (').


- Aditya Webservices Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to Pass Value from struts Action class to java script
 
Similar Threads
can i pass a variable through javascript function to another struts jsp page?
Struts 2 - Using onclick in a radio tag
Onclick in struts.
[solved] passing 3 times by default through action using struts 2
passing jsp variable to java script function on same page