Just assign the value to your Javascript variable.
<script type="text/javascript">
var count = '<%= totalCount %>';
</script>
But using scriptlets been highly discouraged and shift to JSTL
as soon as possible.
Read : How to avoid Java code in JSP files?
As others pointed out, do not create unnecessary hidden elements on DOM. If you really want to use this variable across files declare this variable on top. Even before script includes, so that it avail across all the files.
Example:
<script type="text/javascript">
var count = '<%= totalCount %>';
</script>
<script type='text/javascript' src='js/blah.js'></script>
<script type='text/javascript' src='js/blahblah.js'></script>