I have an embed tag like
<embed id="player" style="height:100%;width:100%"src="../PlayAudio2" controller="true" autoplay="true" autostart="True" type="audio/wav" />
I can able to play a file from servlet doGet
File file = new File("Z:/53611.wav");
FileInputStream fis;
byte[] buffer=null;
try {
fis = new FileInputStream(file);
buffer= new byte[fis.available()];
fis.read(buffer);
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
response.setContentType("audio/vnd.wave");
try {
response.getOutputStream().write(buffer);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
is there a way to do in spring i tried
<embed id="player" style="height:100%;width:100%"src="PlayAudio.html" controller="true" autoplay="true" autostart="True" type="audio/wav" />
with the requesthandler code same as in servlet,but here not even the request received for PlayAudio.html
.how can i do in Spring.
EDIT : controller
@Controller
@RequestMapping("main")
public class ApplicationController {
@RequestMapping(value="Login.html",method=RequestMethod.POST)
public String showhome(){
return "home";
}
@RequestMapping(value="PlayFile.html",method=RequestMethod.GET)
public void playAudio(HttpServletRequest request,HttpServletResponse response){
System.out.println("--playFile");
File file = new File("Z:/53611.wav");
FileInputStream fis;
byte[] buffer=null;
try {
fis = new FileInputStream(file);
buffer= new byte[fis.available()];
fis.read(buffer);
fis.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setContentType("audio/vnd.wave");
try{
response.getOutputStream().write(buffer);
} catch (IOException e) {
e.printStackTrace();
}
}
}
i have Home.jsp in main folder under webcontent which has
<embed id="player" style="height:100%;width:100%" src="PlayFile.html" controller="true" autoplay="true" autostart="True" type="audio/wav" />
and the url mapping
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
but its not working(no request is received for PlayFile.html
handler)