• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in writing Tif file using ServletOutputStream

 
vinoth sathiya
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,

Iam using tif file to show in jsp page.

when i use jpg file means it is showing correctly. but if i use tif file means nothing is showing.

below is my code:

ServletOutputStream servletOutputStream = response.getOutputStream();
inpfile= "D://test.tif";
try{
response.setContentType("image/tiff");
response.setContentType("image/tif");
response.setContentType("image/jpeg");
response.setHeader("Content-Disposition", "inline; filename=test.tif") ;

FileInputStream fin = new FileInputStream(inpfile);
BufferedInputStream bin = new BufferedInputStream(fin);
BufferedOutputStream bout = new BufferedOutputStream(servletOutputStream);
int ch =0;
while((ch=bin.read())!=-1)
{
bout.write(ch);
}

bin.close();
fin.close();
bout.close();
servletOutputStream.close();
}
catch(Exception e){
e.getMessage();
System.out.println("this is inside catch block:"+e.getMessage() + e.toString());

}
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you really setting the content type three times? How do you imagine that would work, especially since they have conflicting information? The last one says JPEG, so that's what will get used.
 
vinoth sathiya
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,

I have commented other setContentType("jpg")

I set to only response.setContentType("image/tif");

after this also not working....

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Searching for "tiff image content type" indicates that the content type should be "image/tiff".

I'm just noticing that you're using the "inline" attachment designation - that won't work, browsers don't display TIFF images.

If you still can't get it to work after addressing these, tell us what exactly "this also not working" means.
 
vinoth sathiya
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
Thanks for addressing.

I have changed contentType to "image/tiff"

and

i have some doubt about response.setHeader(String val,String val);

what i have to set for tiff file format? instead of "inline" Header?

Can you give some example?

Sorry to say again...



Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"attachment" would be appropriate. If you search for the "Content-Disposition" header I'm sure you can find more information on this.
 
vinoth sathiya
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried "attachment" instead of "inline" in Content-Disposition.

No success...

is this coding problem or browser settings problem?

I tried Content-Disposition with different value.but not working.


any suggestions?


Thanks.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does "no success" mean? Post a SSCCE (<-- that's a link) of the code you're using.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!