WebSphere Portal Server - output an image from a database - set content type?????

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > September 2005 > output an image from a database - set content type?????





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author output an image from a database - set content type?????
jjpmip

2005-09-20, 7:54 am

I have some images in a ms sql 2000 server and what i want to do is display in a portlet. When ever I call the database and try to set the content type as image/jpeg I get lots of errors. Apparently you can only set the content type to text/html. Do you g
uys have any suggestion on how to do this or what would be the best way to display the images from a server inside a portlet. Thanks so much L
Michael Harris

2005-09-21, 2:50 am

Search this newsgroups for other questions like this. It has been
answered many times.

You can't output the bytes of the graphics from the portlet. You have
to have some other mechanism (such as a servlet packaged with the
portlet inside it's .war file) to serve up the bytes of the graphic.

Remember, portlet output is aggregated. The output of your portlet is
combined with the output of other portlets on the page and the themes
and skins to build an entire page. When the browser requests a graphic,
it expects not only the correct mime type, but also the bytes of the
graphic and nothing else in the HTTP stream.

Think about it for a minute. Even if you were to code a portlet such
that it could write out the bytes of a graphic, when the browser calls
the URL to get the bytes, it's going to get a bunch of bytes in the
wrong format because what it thinks are the first few bytes of the
graphic will actually be the HTML markup output from the themes and
skins. Within the first couple of bytes or so, the browser will realize
that the bytes aren't a graphic and will throw the data away. You can't
mix HTML and binary graphic data together in the same stream and expect
the browser to figure out the right thing to do.
jjpmip

2005-09-21, 5:55 pm

Thank you Michael, it make sense the way you explained it. Incase you are wondering I ended up creating a servlet that would server the images out as you sugguest and it has been working great. Thank you very much for the help. L


Search this newsgroups for other questions like this. It has been
answered many times.

You can't output the bytes of the graphics from the portlet. You have
to have some other mechanism (such as a servlet packaged with the
portlet inside it's .war file) to serve up the bytes of the graphic.

Remember, portlet output is aggregated. The output of your portlet is
combined with the output of other portlets on the page and the themes
and skins to build an entire page. When the browser requests a graphic,
it expects not only the correct mime type, but also the bytes of the
graphic and nothing else in the HTTP stream.

Think about it for a minute. Even if you were to code a portlet such
that it could write out the bytes of a graphic, when the browser calls
the URL to get the bytes, it's going to get a bunch of bytes in the
wrong format because what it thinks are the first few bytes of the
graphic will actually be the HTML markup output from the themes and
skins. Within the first couple of bytes or so, the browser will realize
that the bytes aren't a graphic and will throw the data away. You can't
mix HTML and binary graphic data together in the same stream and expect
the browser to figure out the right thing to do.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com