javascript - Access a js file from java in a project with tomcat directory structure (java.io.FileNotFoundException) -
i should call javascript function java.
i use scriptmanager:
scriptenginemanager factory = new scriptenginemanager(); scriptengine engine = factory.getenginebyname("javascript"); engine.eval(new java.io.filereader("js/myjsfile.js")); invocable inv = (invocable) engine; boolean val=(boolean)inv.invokefunction("check", value);
i obtain java.io.filenotfoundexception.
my project uses tomcat directory structure:
-java src -webcontent index.jsp ->js-> myjsfile.js ->jsp ->web-inf ->meta-inf
how access js/myjsfile.js java file?
edit resolved
string path = request.getservletcontext().getrealpath("/js/myjsfile.js");
you use absolute path read js file , absolute path of "catalina.home" can system property.
Comments
Post a Comment