Actually, the content type has already been set long before the portlet gets called. You need to start at the beginning of the render pipeline, specifically with the screen.
You have to create your own screen. Do this by extending org.apache.turbine.modules.screens.RawScreen, implementing getContentType and doOutput. In getContentType, return the appropriate MIME string for your content, and in doOutput toss out the raw bytes using the output stream returned by the following call: ServletOutputStream output = rundata.getResponse().getOutputStream(); I use a parameter on the URL to indicate which image I want when I invoke the screen, i.e.: http://localhost:8080/jetspeed/portal/screen/DownloadImage?image=1234 Both of the aforementioned methods grab the "image" parameter and use the value as the key to find the image in the DB. This is the URL that I use in my <img ...> tag. My screen is called Download image, so I generate this URL in my action code like so: DynamicURI download = new DynamicURI(rundata, "DownloadImage"); download.addQueryData(ZbAppConstants.APP_IMAGE_TAG, imageID); Oh, and just as an aside, you probably want read and cache the entire DB row that contains the image in the call to getContentType as this will save you a round trip to the DB. I believe that you also have to do some stuff with your TurbineResources.properties files, but I don't recall exactly what. I'll leave that as an exercise for the reader. -- Michael On 5/10/04 10:19 AM, "Stuart Belden" <[EMAIL PROTECTED]> wrote: > Have a servlet that fetches the data from the db and streams it? Set > the content type in the response to image/jpeg or whatever and in your > html do: <img src="/ImgServerServlet?id=12" alt="this is a db image"> > > hth, > stu > >>>> [EMAIL PROTECTED] 05/07/04 04:37PM >>> > Hi. > Actually I'm storing images on the DB. Until there, everything is OK. > The > problem is displaying it again in the browser. > In the mailing list I found something like implement a RawScreen from > Turbine, but I didn't understand it... > Does anybody knows how can I display a java byte[] data as a jpg on the > > browser??? > > Thank you very much!! > > Carlos. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
