*
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to Pass Value from struts Action class to java script
 
Similar Threads
Struts 2 - Using onclick in a radio tag
passing jsp variable to java script function on same page
[solved] passing 3 times by default through action using struts 2
can i pass a variable through javascript function to another struts jsp page?
Onclick in struts.