File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes check if there is a gif viewer 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 » Frameworks » Struts
Bookmark "check if there is a gif viewer" Watch "check if there is a gif viewer" New topic
Author

check if there is a gif viewer

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Hi, guys:

I have the following problem:
A gif file as InputStream will be fetched from database once
user clicks on image link. Inside my action class,
I want to check if there is a suitable gif file viewer, if
yes, I want to display it.

How can I do it?

thanks a lot
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
What do you mean by a "gif file viewer"?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
I mean any viewer (browser such as IE, Netscape, etc) that can display
this image. Actually, if I click image link inside IE, it will ask me if
I want to open it or save it. For Netscape, it only allows me to save it.
I need to display it if the browser I am using is capable of doing it.
If not, then save it.

Originally posted by Lasse Koskela:
What do you mean by a "gif file viewer"?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
How about checking whether the HTTP request's "Accept" header includes the string "image/gif"?

Which version of Netscape are you talking about, by the way? You see, I haven't bumbed into a single web browser that doesn't display GIF images (except for Lynx and Links, which are character-based browsers)...
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
I cant understand why you getting the message do you want to save the image instead of displaying it in the browser. Can you check the html code in the page.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Have you forgotten to set the content-type header to "image/gif" when you write the image content to the ServletOutputStream?
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Thanks for your reply:

You are right. I did not make my question clear. Actually, what I wanted
is to display image first. If user can click on an image link, she surely can
display it on the very same browser.
[ May 19, 2004: Message edited by: rick collette ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: check if there is a gif viewer
 
Similar Threads
How to copy a internet animation gif file to local
Image problem, urgent!!!
applet doesn't get gif in browser from jar
display tick mark
Getting the Key from a properties file