Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using servlet and writing html code in it.

XML
String audiosrc = path + "\\" + files;
                       out.println(audiosrc);
                       out.println("<audio controls>");
                       out.println("<source src=\" ' + audiosrc + '  \" type=\"audio/mpeg\">");
                       out.println("Your browser does not support the audio element.");
                       out.println("</audio>");



here I have passed variable as a src for audio, but it ain't working, And I want to set the dynamically assign the src value. :/
Posted
Comments
Afzaal Ahmad Zeeshan 13-Sep-15 7:57am    
I would recommend that you give "String concatenation" a second look. :-)

1 solution

Please try like below:
Java
out.println("<scource src=\"" + audiosrc + "\" type=\"audio/mpeg\" >");
 
Share this answer
 
v2
Comments
Member 9671810 13-Sep-15 9:15am    
when I press play. then it shows -->Error: An unknown error occurred.
[no name] 13-Sep-15 11:39am    
See below check lists to resolve problem:

Make sure the audio file path correct.
Make sure audio type(mpeg..)
Make sure your browser support Audio tag because it is a HTML 5 tag.
Member 9671810 13-Sep-15 14:22pm    
there is problem with path only,if I just save in the project it works but if I try to fetch from other folders of drive it ain't working,

<pre lang="HTML">


</pre>

this ain't working.


this works if is just specify only song name and store it in a current working directory.

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