• Post Reply Bookmark Topic Watch Topic
  • New Topic

retrieve images from ftp location to webpage using jsp  RSS feed

 
nagaraju dameruppula
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
I need a code for reading and displaying images in JSP from server folder path.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't.
You provide a servlet whose job is to get the image and return it based on whatever input comes from the client request.

In short, when the client gets the HTML page it parses it and finds any other bits it needs (you'd see this happening if you used the debug tools available with most browsers). It gets these bits as separate requests to the server.
This includes <img> tags.

So you need to provide an end point on your server (the above servlet) which will stream back images based on any extra parameters in the img tag.

Note that in all the above I make no mention whatsoever of JSP. We are solely dealing with HTML on a client, specifically an <img> tag, and a servlet.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, you never do I/O of any kind in a JSP. You can use a JSP to generate the HTML page that shows the images, though.
 
nagaraju dameruppula
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:You don't.
You provide a servlet whose job is to get the image and return it based on whatever input comes from the client request.

In short, when the client gets the HTML page it parses it and finds any other bits it needs (you'd see this happening if you used the debug tools available with most browsers). It gets these bits as separate requests to the server.
This includes <img> tags.

So you need to provide an end point on your server (the above servlet) which will stream back images based on any extra parameters in the img tag.

Note that in all the above I make no mention whatsoever of JSP. We are solely dealing with HTML on a client, specifically an <img> tag, and a servlet.




Thanks Dave.
I got it.but how do is pass image that is read from ftp.
How the JSP display the image that is returned from Servlet

Please suggest me with some sample code.
 
Dave Tolls
Ranch Foreman
Posts: 3068
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP doesn't display the image.
The client does, based on the <img> tag.

So:

The client will then send a request to the server.
If someServlet is mapped to your servlet that knows how to find images, then that will get called.

Your servlet will use the identifier to find the image, and stream it back to the client, for which there are plenty of examples on the web.

So your job now is to come up with a way to identify an image (it could even be the path to the image on the ftp server), write some FTP code that uses that identifier to find the image, then stream it from the FTP server to the client.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How the JSP display the image that is returned from Servlet


Once again we see the importance of using the right words to describe what is going on. A JSP page just writes HTML which is interpreted by a browser - any time you say a JSP is doing anything else you are confusing yourself. Use the right words and many problems become simple.

Bill
(the elderly curmudgeon programmer)
 
nagaraju dameruppula
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave.
your suggestion worked.
@william:Im using the servlet to read an Image that will be displayed in JSP using image tag.

Thanks all.
 
nagaraju dameruppula
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Can somebody suggest me how to display images in jsp that are stored in ftp folder?


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!