Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Embed TIFF image in response  RSS feed

 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I want to embed a tiff image in my web page.
so I have my jsp/html page, having


in my servlet class (actually it's a struts Action class, but it's the same thing with servlets) I have something like this:



The same code works fine for jpeg images (changed content-type accordingly), but not for tiff images.

The browser has a plugin installed for tiff image display (alternatiff), which works (i can open a tiff file and see it). I can only imagine that the response needs some parameter that I can't think of...

Any ideas?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The contentType header should do it for you however MSIE sometimes ignores the content type header and looks at the file extension instead.

Try adding a Content-Disposition header which allows you to suggest a filename to the browser.

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not familiar with the plugin, but are you using IE by any chance? IE is not particularly good at recognizing filetypes by looking at the mimetypes. Try something like
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the suggestions,but neither works ...

i am testing on both IE and firefox.

i just can't figure out why it doesn't work!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try putting a static tiff file on a server and hitting it with the browser? You said you opened one. I'm assuming you opened it as a local file.

Also, just to be sure your servlet is working properly, did you try saving the generated tiff file to your hard drive and opening it with a program that knows how to deal with tiffs (photoshop, the Gimp, etc..)?
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, you are right, I only tried to open as local file, or other tiff files from the internet.

i made sure of course that the generated tiff file is correct, that was the first thing I thought was wrong, but it's just fine.

I have tried your suggestion to put the static image and then added in my page:



and it doesn't load! I never expected this ...

in IE this static loading results in an empty space with an icon that represents an unloaded image, while the other old ones have icons that suggest "dead" images.
firefox shows all of them "dead"

why do you think this happens? could this be tomcat's fault?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Diana Pop:
could this be tomcat's fault?


I tend to doubt it.
The defaultServlet in Tomcat is what serves up static files.
It serves them up verbatim and is working in countless applications; has been for a long time.

I'm using Tomcat 5.5 right now and I just checked; it does have mime mappings for tiff files so it's not that.

Have you verified the mime associations for your plugin in MSIE (I can't remember where they're located off hand) to make sure that the plugin is registered for that type?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the tiff file someplace where I can reach it?
If it's small, I'd be happy to put it up on an Apache server for you to try.
This would rule out Tomcat.
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, this question may be very stupid, but i'll ask it anyway:
do tiff images even work in html? :roll:
when i wanted to verify the plugin, i tried to find pages that contain tiff files, but i only found links to the files, and previews as jpeg or png.
so maybe html code, text + <img src ="*.tiff"> isn't even supposed to work?


the file is small, it'd be great if you could put it up. i hope this works:
http://www.driveway.com/lhhze82508
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you read the documentation that came with the plugin?
Your last question is making me wonder if it is expecting to be used with an <object /> tag instead of an image tag.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Diana Pop:
[QB]ok, this question may be very stupid, but i'll ask it anyway: do tiff images even work in html?

Well, normally they don't work. This plugin must hook into IE on a pretty low level.

But didn't you say that the plugin worked fine? Or was that just for isolated images, and not for inline images on a web page? Sounds like a question for the plugin documentation.
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry, i never even thought that it can't be treated as a normal image, just like any jpeg.
i only tried to test with isolated images, it's true. later on, when i couldn't find any test pages containing inline images i started to ask myself if it's even possible.

thank you for your suggestions, i guess the easiest way to do what i want is transform the tiff in a jpeg in my servlet and send the jpeg image in the response.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the name of this plugin?

It seems odd that someone would offer a browser plugin for viewing an image type that doesn't allow them to be viewed within a web page.
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
www.alternatiff.com
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i scanned their docs (and checked the source of their test page) and it seems that img src is not used, but rathet a tag <object /> or <embed />.

testing it now...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was my guess (my post asking that came in at the same time as Ulf's so it might have been missed).

The nice thing about using an object tag is that you will have a way of delivering the plugin to your clients when they need it. If it worked by changing how the browser handles <img ../> tags then you would have to find a way to get your clients to install the plugin before they try to read your pages.
 
Bucsie Dusca
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried to post yesterday, but i got some error messages from the site,and didn't wont to double-post:
object and embed tag both work, thank you.

i have another follow-up question, browser - related. maybe you can suggest something ... i can set in my embed tag a href="url" target="_blank" so that when the user clicks an image it can link somewhere else. this works fine in firefox, but i just can't get iexplorer to follow the link. the cursor changes when i move it over the image, so it sees that the image is a link, but clicking has no effect. is this a security limitation, configurable in options? i'm thinking the plugin is an activeX and maybe it's not allowed to open new windows? i turned off the popup blocker but that had no effect.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!