• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

dispaly images from file system in a web page

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way available to display the images stored in a file system path in a JSP page using direct reference with <IMG> tag.

E.g: <img src="file system path"+"image name" />. Since these images are of bigger size, its difficult to place them in web context

quick help appreciated
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it is not possible.
Even if you specify the file system's location in img tag it will search in the computer where your JSPs are running.
So always all paths should be relative to your web application.
Anyve you can do this using servlet.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Surya Kant wrote: it will search in the computer where your JSPs are running.


That is not correct. File systems paths address files on the system where the browser is running. JSPs run on the server.

But yes, to serve files that lie outside a web app, a servlet can be used to read the file ad stream it as the response.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Create a servlet which does the task. Here's an example: http://balusc.blogspot.com/2007/04/imageservlet.html
 
Prabhakar Aluri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the responses posted. Yes I read the files from a Servlet and streaming them in response.

Appreciate the help.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic