aspose file tools*
The moose likes Servlets and the fly likes View JPG Image from Servlet File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "View JPG Image from Servlet File" Watch "View JPG Image from Servlet File" New topic
Author

View JPG Image from Servlet File

Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
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

Joined: Jan 10, 2002
Posts: 61606
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
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

Joined: Jan 10, 2002
Posts: 61606
    
  67

Ah, you need some help with the servlet itself. I'll move this to the servlets forum for you.
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
Try something like the following code for sending the file to the client:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: View JPG Image from Servlet File