This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
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?
[solved] passing 3 times by default through action using struts 2
Struts 2 - Using onclick in a radio tag
Onclick in struts.
passing jsp variable to java script function on same page