I have to display a background image of a jsp page using jquery. The name of the image file is available in static member of a Java class. I tried like, created a static member in a Java class (ImageClass)
public static final String img_file="welcome.png"
and in jsp file, I imported this java class and inside script tag
$(document).ready(function () {
$('body').css('background-image','url(/resource/'<%=ImageClass.img_file%>')');
});
But the image is not getting displayed and I am sure the image is available in the mentioned path. Am I doing anything wrong ? Is this the rite way to do ? Any help will be appreciated.
you wrote
try instead
without quotes around the server side echo, otherwise you may have a js parsing error.