output an image from a database - set content type?????
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > output an image from a database - set content type?????




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-20-05 12:54 PM

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 d
isplay the images from a server inside a portlet. Thanks so much L





[ Post a follow-up to this message ]



    Re: output an image from a database - set content type?????  
Michael Harris


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-21-05 07: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.





[ Post a follow-up to this message ]



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


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
09-21-05 10:55 PM

Thank you Michael, it make sense the way you explained it. Incase you are wo
ndering I ended up creating a servlet that would server the images out as yo
u 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.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 07:12 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register