Bookmark Topic Watch Topic
  • New Topic

displaying an image of type TIF

 
Santosh Raveendran
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Report post to moderator
can any one advice on how to display an image of type TIF in a jsp

Thanks
santhosh
[ November 26, 2008: Message edited by: santosh raveendran ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Report post to moderator
JSPs dont display images - they write HTML tags that tell the client browser where to get the image in a separate request/response cycle.

Get your image display working with static HTML tags first, then figure out how to get JSP to write that tag.

Bill
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Few (No ?) browsers can display TIFF out of the box. There's a plugin called http://www.alternatiff.com/ but it only works on Windows.

Maybe a better approach would be to convert the TIFF to something more universal -like PNG-, and serve that instead?
 
Santosh Raveendran
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Report post to moderator
William,Ulf

I have implemented the below solution for displaying the image of extension tiff.

Struts implementation

public ActionForward execute(ActionMapping map, ActionForm form,HttpServletRequest request,
HttpServletResponse res) throws Exception {
System.out.println("Inside TiffFileDisplayAction");

FileInputStream inputStream;
byte[] buf = new byte[512 * 1024]; // 512K buffer
try {
//File file=new File("D://avinash//ss.pdf");
//inputStream=new FileInputStream(file);
//byte[] buf=new byte[inputStream.available()];
//inputStream.read(buf);

//String fileNames = "Example.pdf"; //(String) request.getParameter("fileNames");
//String fileExtension = fileNames.substring(fileNames.lastIndexOf('.')+1);
//inputStream = new FileInputStream("E://TifImage//Example.pdf");
inputStream = new FileInputStream("E://TifImage//Sample.tif");
//byte buf[]=new byte[1024];
int len;
res.setContentType("application/tiff");
res.setContentLength(buf.length);
//res.setHeader("Pragma", "no-cache");
res.setHeader( "Content-Disposition", "inline; filename=Sample.tif");
ServletOutputStream out = res.getOutputStream();
//out.write(buf, 0, buf.length);
while((len=inputStream.read(buf))>0)
out.write(buf,0,len);
out.close();

//buf = centeraService.retrieveFileFromCoupon(clipArtID);
//showPDFForScreen(buf,fileExtension);
//showPDFForScreen(buf,fileNames,fileExtension.trim(),res);

} catch (Exception e) {
e.printStackTrace();
}
return map.findForward("success");
}


Thanks
santhosh
 
    Bookmark Topic Watch Topic
  • New Topic