This is client-side matter, just use JavaScript or jQuery will do. Adapt from this sample code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("links").on("click", "a", function(e){
e.preventDefault(); // cancel redirecting
var txt = $(e.target).text();
alert(txt);
});
});
</script>
</head>
<body>
<div class="links">
<%
out.println("<a href=\'"+ webTempPath + "/1.mp3\'>");
out.println(files);
out.println("</a>");
%>
<%-- other hyperlinks --%>
</div>
</body>
</html>
Google to find out more about jQuery.