Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

View JPG Image from Servlet File

 
Kondal reddy
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, you need some help with the servlet itself. I'll move this to the servlets forum for you.
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try something like the following code for sending the file to the client:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic