Click here to Skip to main content
15,889,176 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have fetched the stored mp3 files in form of hyperlink in jsp using html5 tags. But I want when I click on certain link I want that mp3 to played.Here is my code.

<audio controls="">

Your browser does not support the audio element.
<%

String webTempPath = "D:\\nameoffolder" + "\\" + (session.getAttribute("uname"));


String path = webTempPath.toString();

String files;
File folder = new File(path);
File[] listOfFiles = folder.listFiles();


out.println("<table boder=2 align=center>");
out.println("<head>");
out.println("<br/>");
out.println("MY PLAYLIST");
out.println("</head>");



for (int i = 0; i < listOfFiles.length; i++) {

if (listOfFiles[i].isFile())
{
files = listOfFiles[i].getName();
if (files.endsWith(".mp3"))
{
out.println("<tr>");
out.println("<td>");
// out.println(files);
out.println(i+1);

out.println("<a href=\"mypage1.jsp\">");
out.println(files);
out.println("</a>");
out.println("<br/>");
out.println("</td>");
out.println("</tr>");
}
}

out.println("</table>");
}

%>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900