Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to hide image path in JSP

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to hide image path which we are displaying on our website i.e. any user when do right click and view source, the path should be in encrypted form.
So that whenever anyone copy the image url and copy that url in any browser the image should not display.

We display our image in following way

<img src="http://www.abc.com/3562356.jpg"; width="150" height="150" ></img>

Where www.abc.com is a server in which all these .jpg files are uploaded.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no way to accomplish this. If the browser can show the image, it is available to the end user.

You can make it harder to download the image, but you cannot prevent it.

(And please, don't even think of trying to do something as silly as disabling right-click.)
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have the image resource served by a servlet and use an identifier for the image that has nothing to do with the file name.

You might encrypt the name with the session ID, thus the link would be useless after the user left the session.

Bill
 
Marshal
Posts: 25823
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen people do things in that servlet like checking the referrer header, to ensure that the request is coming from the page in which the image is supposed to appear and from nowhere else.

Of course the referrer header can be faked, but it's like Bear said, you can't prevent people from accessing the image, you can only make it harder.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could use say a servlet to display the image or perform some weird doohickey like make an AJAX call with a HTTP header that uniquely identifies your request. But these can be faked.

you can only make it harder.



Very true
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I strongly suspect (only because 99.99999% of the times that this question is asked this is true) that the OP wants to prevent people from saving the image to their own systems. So no matter what gyrations are used to present the image in the browser, once it's visible in the browser, the user can save the image to their system.
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:I strongly suspect (only because 99.99999% of the times that this question is asked this is true) that the OP wants to prevent people from saving the image to their own systems. So no matter what gyrations are used to present the image in the browser, once it's visible in the browser, the user can save the image to their system.



Not to mention proxies that could cache an image, if you are worried about image theft.

Just saying that is something to consider based on what the OP wants
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah ... Bear said it right...Once displayed in browser .. no one can stop the person from saving it...
Even if you use scripts ... one can take a screenshot and crop out the required image out of it....
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic