• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in viewing uploaded images

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have created an upload form to upload some images.The server is Tomcat and I am using eclipse to develop the JSP.
During the upload the images in the form are store on different drive than what the server is running on.

After uploading, I tried to use a JSP which uses the images.In the JSP, I have specified the absolute path for the image.
I am able to see the images on the eclipse internal browser.But when I use Firefox I cannot see the images.
What could be wrong.Is it because the images are not in WEB-INF.?

Cheers,
Sam
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,

Is it because the images are not in WEB-INF.?


I dont think this can be a reason. If this is the reason, you shouldn't have seen them in the eclipse internal browser as well.

During the upload the images in the form are store on different drive than what the server is running on.



Please be clear. I couldn't understand, what you mean to say.
[ May 23, 2008: Message edited by: Prasad Tamirisa ]
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi There,
I have installed tomcat in C drive and the during the image directory is in D drive.
In eclipse when I select...run as->run on server...i can see the images on the eclipse internal browser.But when I copy the same url onto Firefox..I can see only the text but not images.Note in the jsp I have given the complete path for the image.

Cheers,
Sam
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that mean the HTML contains image paths like "D:\foo\bar.jpg"?
 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you enter a path with a drive name, like "d:/myimages/img1.jpg"?
If that is the case, your remote users will not be able to see the pictures. They are only visible on a browser running on the server.
You have to make sure that the pictures are served via your web server.
Putting them under web-inf can help. You have to use a relative path in that case.

example: pictures in web-inf/images , than your path could be /images/img1.jpg"
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jan Cumps:
You have to make sure that the pictures are served via your web server.
Putting them under web-inf can help.


Actually, putting them under WEB-INF ensures that nobody can see them, because nothing gets served directly out of that directory. The images need to be in a publicly accessible directory, like the one WEB-INF itself is in.
[ May 23, 2008: Message edited by: Ulf Dittmer ]
 
Jan Cumps
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True. My mistake. I ment to say in a subdir of the application root.
 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.Yep I am using absolute path like "d:\\images\image.jpg".

I have the eclipse workspace in different folder path than tomcat
ie my application is in d:\\workspace\\website and tomcat is installed in c drive.

While reading from the form if I start dumping the images into d:\\workspace\\website\\WebContent\images\\
will it work?I am quite doubtful that eclipse will be able to detect the dynamic changes taking place in the image directory and sync with the server instance.Is there a folder in tomcat that I can put the images?.
Cheers.
Sam
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sam barker:
Thanks for the reply.Yep I am using absolute path like "d:\\images\image.jpg".



When you use an absolute path in an image tag like that, you're telling the user's browser to go the the image file from that location.
Unless the user has a file named 'image.jpg' in his/her "d:\\images" directory, they will never be able to see it.

Instead, put the image in your webapp's directory structure and create a url that is relative to the context path.
If you're not sure how to do that, see:
http://faq.javaranch.com/java/ResourceUrlProblems
 
reply
    Bookmark Topic Watch Topic
  • New Topic