Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to call a servlet from css?

I'm trying to move all the images stored in web application folder to a database. And calling them with a servlet. Is it possible to call a servlet from my css ?? or is there any way to call a remotely stored image file from css??

I tried to call a servlet method from CSS.But couldn't succeed. Is it possible to call a method like this?

background-image: url(servlet/com.abc.servlet.GetImage?name=home&GetImage('abc','123'));

like image 353
coder247 Avatar asked Dec 18 '22 01:12

coder247


1 Answers

Yes. As long as the images have urls, you can use it in your css.

For example:

background-image:url('/getimage.ashx?id=3');

You can even go a step further an reroute their urls - you can even use the same urls you have today, but having your server handle the request and loading files from the database.

Another tip: make sure you set the right headers. You want to use the correct content type, and probably want the images cached properly on the client side.

like image 144
Kobi Avatar answered Jan 19 '23 05:01

Kobi