This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes displaying an image of  type TIF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Reply locked New topic

displaying an image of type TIF

Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83
can any one advice on how to display an image of type TIF in a jsp

[ November 26, 2008: Message edited by: santosh raveendran ]

Thanks, Santhosh
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
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.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41155
Few (No ?) browsers can display TIFF out of the box. There's a plugin called 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?

Ping & DNS - my free Android networking tools app
Santosh Raveendran
Ranch Hand

Joined: Jun 29, 2008
Posts: 83

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()];

//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.setHeader("Pragma", "no-cache");
res.setHeader( "Content-Disposition", "inline; filename=Sample.tif");
ServletOutputStream out = res.getOutputStream();
//out.write(buf, 0, buf.length);

//buf = centeraService.retrieveFileFromCoupon(clipArtID);

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

I agree. Here's the link:
subject: displaying an image of type TIF
Similar Threads
Looking for image viewer applet. Please Help.
Displaying TIF Image
SCPJ2 LOGO convert to .bmp
Displaying TIF Image
Problem regarding logo