wood burning stoves 2.0*
The moose likes JSP and the fly likes Unable to get the image from external folder? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to get the image from external folder?" Watch "Unable to get the image from external folder?" New topic
Author

Unable to get the image from external folder?

Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
Hi all,
As i unable to get the image from the external folder . that is when i am accessing my web application with IP address from other system i could not get the image on the screen . i kept that image into outside of the application.

for example
when i am accessing the application in local machine:
this is the url

http://localhost:9080/Fun/index.html

i am getting image .

but not in the below url.
from other's machine

http://192.168.0.21:8090/Fun/index.html

here the image that i access in the screen points to local drive. so it's not coming when accessing from the other's machine with ip.

thanks
Ganesan
Vinoth Thirunavukarasu
Ranch Hand

Joined: Dec 18, 2008
Posts: 164

[Edit: not-so-nice response removed.]


Java Best Practices
Linux Best Practices
Amortization Calculator

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42056
    
  64
What is the URL you're using in the img tag's "src" attribute?


Ping & DNS - my free Android networking tools app
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
this is the url "D:/img/sample.jpg"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

That is a URL to a file on the file system. Do you expect your clients to all have that file there on their own computers?



[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Use relative paths instead of real paths.

Ananth Chellathurai


Ananth Chellathurai [Walk on software]
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
Bear Bibeault :- No, Actually the image folder i kept outside from the application. ie .war file in server path. img folder in outside folder.

Ananth Chellathurai :- i am using real path because of i kept the img folder outside of the application.


Thanks
Ganesan.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Ganesan Ramakrishnan wrote:Bear Bibeault :- No, Actually the image folder i kept outside from the application. ie .war file in server path. img folder in outside folder.

My point is that when you use a file path URL like that the browser looks for the file on the local system. Is that what you want? Obviously not.
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
Then Is there anyway to access the external files apart from relative path?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

No. The file either needs to be addressable by a URL, or you'll have to write a servlet that can read the file and serve it.
Ganesan Ramakrishnan
Ranch Hand

Joined: Mar 18, 2008
Posts: 89
Thanks Bear...
 
GeeCON Prague 2014
 
subject: Unable to get the image from external folder?