i want call function of javascript servlet.
servlet code:
file ff = new file(uploadedfile+"/"+filename+".mp4"); fileoutputstream fileoutst = new fileoutputstream( ff ); fileoutst.write(data); fileoutst.close(); request.setattribute("src", ff); requestdispatcher dispatcher=request.getrequestdispatcher("/web-inf/jsfunction.js"); dispatcher.include(request, response); my javascript code:
myfunction(fileinput) { var fileurl = window.url.createobjecturl(fileinput); } the problem javascript calls display code content not execute it. how can fileurl.
several things wrong here:
first, inclusion of javascript source improper, because javascript must included (or referenced) always within html file. in case, instead, serving mp4 file.
if must absolutely execute js code (remember js executed in browser), suggest serve html page instead. in case, jsfunction.js script must referenced within html code:
<html> <head> <script type="text/javascript" src="jsfunction.js" /> </head> <body> ... </body> </html> second: if include script, must invoke function. can call immediately, scriptlet, or response client event (onclick, onload, etc).
Comments
Post a Comment