0

I have a HTML file which has images. I want read this file from local folder like C:/data using java and display it on browser along with images when request comes from client(other than localhost).

Venkat
  • 62
  • 8
  • First I read HTML page and where ever i find `SRC` attributes in it I am replacing `src` value with absolute path (C:/data/img.png) but when i request from other machine this wont work... – Venkat Jun 17 '14 at 10:39
  • it's normal that it won't work because the other machine doesn't know what is `C:/data/img.png` .what you have to do is when you find an src attribute is to copy the ressource from the C location to a folder behind your HTML let's call it images, so if your image is in images/img.png then set 'images/img.png' as the value of the src attribute. – Mifmif Jun 17 '14 at 10:44
  • Thanks.. but I have to stream the image along with HTML page but not to store them in a folder. Is there any way to do this..!? – Venkat Jun 17 '14 at 10:47
  • 1
    you can do it by loading your images in a 64 encoding inside your HTML check this to have an idea http://stackoverflow.com/questions/2329364/how-to-embed-images-in-a-single-html-php-file – Mifmif Jun 17 '14 at 10:52
  • Thanks for the ref. Is there any way to implement this in JAVA..!? as I can see that its a PHP thing not java.. – Venkat Jun 17 '14 at 11:53
  • 1
    Hmm, unless you have a really complex structure, couldn't you simply use relative links ? `top` = top of your site – Serge Ballesta Jun 17 '14 at 12:29
  • Why do you want the page and images to be directly under c rather than in the webapps folder under Tomcat (or whatever other servlet container)? – developerwjk Jun 17 '14 at 14:06
  • Thanq... but I have a plenty files and images to those, so saving them in server is not a good option @developerwjk – Venkat Jun 17 '14 at 14:42
  • @Venkat, If they're to be served it makes more sense. And that way you know that nothing is served which is not in that area. Having things served from all over the server can open a security hole.... – developerwjk Jun 17 '14 at 14:47

0 Answers0