• Post Reply Bookmark Topic Watch Topic
  • New Topic

dispaly images from file system in a web page  RSS feed

 
Prabhakar Aluri
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
 
Surya Kant
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • 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
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!