Accessing images using basic authentication


I have a simple JSP page that must display an image located on a remote server. This remote server uses basic authentication. The credentials to access the remote image are known to my application.

How can I display the image without prompting the user to enter credentials (username/password dialog).

Any suggestions welcome.


Who is Participating?
PAQd, 500 points refunded.

CS Moderator
>>>>This remote server uses basic authentication

you have to configure your remote server so that it allows users to log in without authentication
frostwAuthor Commented:
>>you have to configure your remote server so that it allows users to log in without authentication

Sorry but that is not an option.
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Why do you want to do this frostw? Why not host the images on your own machine?
frostwAuthor Commented:
We have a server collecting router traffic data and generating graphs (the .png images in question). The graphs are available to external applications via a cgi interface which is protected by basic authention. The images are generated on demand and therefore cannot be hosted locally by my application.

Since I can call Java code from my JSPs I believe I can fetch the images using a URLConnection. This would allow me to cope with the authentication (I think). However, what I don't know how to do is insert the fetched image back into the HTML that the JSP generates.
frostwAuthor Commented:
So I take it this is not possible then?!
frostwAuthor Commented:
No matter, I figured it out myself. Just in case anyone is interested I achieved it using a servlet to fetch the image (using basic authentication) then returned the data with an "image/png" content type.
frostwAuthor Commented:
I am going to ask that this question be closed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.