java - What is the best way to use context-param in JavaScript -
in web.xml set context param "pathtoimages". in jsp files path images files use el, this:
<img src="${initparam.pathtoimages}"/image.jpg" />
but have problem javascript. in js files have code:
setinnerhtml("someplace", "<.img src='images/s.gif'>");
i know isn't beautiful code isn't mine :) cannot pathtoimages in same way jsp. best way this?
pass parameter js function: function createimage(path) {..}
, invoke createimage('${initparam.pathtoimages}')
another, perhaps better option have js variable , initialize desired value. in js file:
var imagepath; function init(config) { imagepath = config.imagepath; }
and in header:
init({imagepath: '${initparam.pathtoimages}'});
Comments
Post a Comment