File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to hide image path in JSP

 
Sapan Shah
Greenhorn
Posts: 25
  • 0
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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.)
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • 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
 
Paul Clapham
Sheriff
Pie
Posts: 20206
26
MySQL Database
  • 0
  • 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.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
Firefox Browser Linux MyEclipse IDE
  • 0
  • 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
 
Tarun Bolla
Ranch Hand
Posts: 89
  • 0
  • 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....
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic