| Author |
How to hide image path in JSP
|
Sapan Shah
Greenhorn
Joined: Jan 01, 2010
Posts: 24
|
|
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.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
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.)
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12266
|
|
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
|
Java Resources at www.wbrogden.com
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16482
|
|
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.
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
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
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56166
|
|
|
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
Joined: Feb 24, 2006
Posts: 6588
|
|
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
|
 |
Tarun Bolla
Ranch Hand
Joined: Jun 20, 2011
Posts: 85
|
|
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....
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: How to hide image path in JSP
|
|
|