how to get the Servelet context path in vaadin

Hi All, I am new to the Vaadin, I am trying to get the images working on my application, there I wanted to get the servelet context path, like http://localhost:8080/contextpath ?

I have placed my images in seperate folder like /VAADIN/theams/mytheams/custom/sample.png

I wanted to get the sample.png in .js file so ima trying to pass the serrvlet contex path to js file.

please help me how to get the context path insted of hard code the abolute image path in .js file.

Thanks & Regards

Without knowing how/where you add the JS file, you can get the context path through VaadinRequest’s getContextPath() method (VaadinRequest is given as a parameter to the UI’s init method). Other alternatives include using JavaScript to finding the context path or maybe in your case, you can use relative paths?