GeeCON Prague 2014*
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


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