• 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

View JPG Image from Servlet File

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can I show JPG file in my jsp ...that jpg coming in servlet as a File format...if any one know help me.
 
Sheriff
Posts: 67747
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
The same way that you show any other image: with an <img> tag. If the image data is being served up by a servlet, be sure that the src attribute of the tag references the servlet as appropriate.
 
Kondal reddy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi bear thanq for responding ...actually my servlet getting like this :



FTPFile[] files = lObjRemote.list();
File file = null;


for (int i = 0; i < files.length ; i++) {
String fileName = files[i].getName();
// ?? ??? ??? ??
String extension = fileName.substring(fileName.lastIndexOf(".") + 1);

//System.out.println("fileName = "+fileName);
System.out.println("in servlet fileName = "+fileName);
long size = files[i].getSize();
//System.out.println("size +"+size);
// ?? ??? 0?? ?? ?? ??? ???
//System.out.println("bfore size");


if ( (size > 0) && ((extension.equalsIgnoreCase("jpg"))||(extension.equalsIgnoreCase("xml")) )) {
file = lObjRemote.get(fileName, fileName);
System.out.println("inside servlet jpg file *** = "+file);
//ftp.put("c://jk","");

}
}


System.out.println("file = "+file);
System.out.println("files = "+files);

so how can take that file into Jsp...have to use FIstream...
 
Bear Bibeault
Sheriff
Posts: 67747
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
Ah, you need some help with the servlet itself. I'll move this to the servlets forum for you.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try something like the following code for sending the file to the client:
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic