This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 88
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: 41137
    
  45
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: 88
this is the url "D:/img/sample.jpg"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

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: 88
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: 60794
    
  65

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: 88
Then Is there anyway to access the external files apart from relative path?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

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: 88
Thanks Bear...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to get the image from external folder?
 
Similar Threads
Strange behavior while accessing the application through IP address
how to store/retrive image in oracle database using struts 1.2
Security error accessing url
strange scenario in WSAD-webspere
accessing the local application through web browser