• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

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: 67590
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: 67590
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:
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic