Re: reading binary stream into xsp page
Eduard, I tried your recommendation and it worked partly but the output to the screen is incorrect. I am getting #0;t#0;h#0;i#0;s#0; written to the screen instead of plain text with out the #0; being written to the screen as well. How do I deal with this? And if the output stream was an image or audio how would I deal with those outputs as well? for instance if: 1. byte[] text = newArt.getArtistPhoto1(); allows me to do xsp:expr>new String(text)/xsp:expr> in my xsp page, how would I deal with: 2. byte[] image = newArt.getArtistPhoto1(); or 3. byte[] audio = newArt.getArtistPhoto1(); many thanks in advance On 12 Feb 2004, at 06:37, Eduard Drenth wrote: On Thu, 2004-02-12 at 01:48, beyaNet Consultancy wrote: Hi, I have the following code in my xsp page: byte[] binImg = newArt.getArtistPhoto1(); I now want to display this stream in the page like so: xsp:expr>binImg/xsp:expr> If this is a textfile try: xsp:expr>new String(binImg)/xsp:expr> but am getting, as expected, casting errors. What do i need to do todisplay the contents of this stream, which was a simple txt file readinto postgresql as a byte array? Any help with this issue will be mostappreciated. many thanks in advance -- Eduard Drenth [EMAIL PROTECTED]> home sweet home - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reading binary stream into xsp page
On Thu, Feb 12, 2004 at 09:22:29AM +, beyaNet Consultancy wrote: Eduard, I tried your recommendation and it worked partly but the output to the screen is incorrect. I am getting #0;t#0;h#0;i#0;s#0; written to the screen instead of plain text with out the #0; being written to the screen as well. How do I deal with this? And if the output stream was an image or audio how would I deal with those outputs as well? for instance if: 1. byte[] text = newArt.getArtistPhoto1(); allows me to do xsp:exprnew String(text)/xsp:expr in my xsp page, how would I deal with: 2. byte[] image = newArt.getArtistPhoto1(); or 3. byte[] audio = newArt.getArtistPhoto1(); you got it all wrong right now. If you (a user working with the browser) request a page that contains both text and graphics then this content is requested separately. So it means that first the html code gets fetched. After that every img tag is being parsed and fetched in separate request. When the browser has all the files needed it renders the page. You do not need to include any binary data in your html code produced by xsp. And the #0; ? If you try to insert binary content into xml it gets escaped (everything that is not text ). lg -- __ | / \ |Leszek Gawron// \\ \_\\ //_/ [EMAIL PROTECTED] _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ | - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: reading binary stream into xsp page
On Thu, 2004-02-12 at 10:22, beyaNet Consultancy wrote: Eduard, I tried your recommendation and it worked partly but the output to thescreen is incorrect. I am getting #0;t#0;h#0;i#0;s#0; written tothe screen instead of plain text with out the #0; being written tothe screen as well. How do I deal with this? Perhaps there is some characterset problem? You could try: new String(text,ISO-8859-1) or whatever charset your getArtistPhoto1() returns And if the output streamwas an image or audio how would I deal with those outputs as well? forinstance if: 1. byte[] text = newArt.getArtistPhoto1(); allows me to doxsp:exprnew String(text)/xsp:expr in my xsp page, how would Ideal with: 2. byte[] image = newArt.getArtistPhoto1(); or 3. byte[] audio = newArt.getArtistPhoto1(); You cannot put binary data in an xsp:expr. You always get the image etc. in your webpage through an extra request from for example a img tag. You have to create a pipeline that delivers the binary data. If the binary data are static you can use a map:read. If the binary data are dynamically generated you may have to write your own reader or a serializer Eduard many thanks in advance On 12 Feb 2004, at 06:37, Eduard Drenth wrote: On Thu, 2004-02-12 at 01:48, beyaNet Consultancy wrote: Hi, I have the following code in my xsp page: byte[] binImg = newArt.getArtistPhoto1(); I now want to display this stream in the page like so: xsp:exprbinImg/xsp:expr If this is a textfile try: xsp:exprnew String(binImg)/xsp:expr but am getting, as expected, casting errors. What do i needto do todisplay the contents of this stream, which was a simple txt file readinto postgresql as a byte array? Any help with this issue will be mostappreciated. many thanks in advance -- Eduard Drenth [EMAIL PROTECTED] home sweet home - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Eduard Drenth [EMAIL PROTECTED] home sweet home - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: reading binary stream into xsp page
I think they understood that you were getting a byte[] field. however, you cannot 'render the binary stream correctly to the page', i.e. you cannot simply embed an image into an html page as a binary stream. as was mentioned, you reference image(s/ streams) via URLs. you can of course have that URL be handled by an XSP that emits the data you get from the db as e.g. a gif image (image/gif), if it was a gif stream. regarding the text: when getting the byte stream you probably don't know what encoding the text is in. and it might differ from the encoding used by the XSP. thus, the text might be parsed and output incorrectly (the nulls you get are the second bytes of each of the multi-byte chars). -Ursprungliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Auftrag von beyaNet Consultancy Gesendet: Donnerstag, 12. Februar 2004 11:30 An: [EMAIL PROTECTED] Betreff: Re: reading binary stream into xsp page lg, you have not understood what I am doing. I am reading a byte[] field from postgreSQL into my xsp page: Artist newArt = new Artist(); byte[] binStream = newArt.getArtistPhoto1(); What I simply want to know is this, how do I render the binary stream correctly to the page if: 1. binStream is an image or 2. binStream is a text document what do I need to do in xsp to correctly display the binary stream as an image or as text? many thanks in advance On 12 Feb 2004, at 10:10, Leszek Gawron wrote: On Thu, Feb 12, 2004 at 09:22:29AM +, beyaNet Consultancy wrote: Eduard, I tried your recommendation and it worked partly but the output to the screen is incorrect. I am getting #0;t#0;h#0;i#0;s#0; written to the screen instead of plain text with out the #0; being written to the screen as well. How do I deal with this? And if the output stream was an image or audio how would I deal with those outputs as well? for instance if: 1. byte[] text = newArt.getArtistPhoto1(); allows me to do xsp:exprnew String(text)/xsp:expr in my xsp page, how would I deal with: 2. byte[] image = newArt.getArtistPhoto1(); or 3. byte[] audio = newArt.getArtistPhoto1(); you got it all wrong right now. If you (a user working with the browser) request a page that contains both text and graphics then this content is requested separately. So it means that first the html code gets fetched. After that every img tag is being parsed and fetched in separate request. When the browser has all the files needed it renders the page. You do not need to include any binary data in your html code produced by xsp. And the #0; ? If you try to insert binary content into xml it gets escaped (everything that is not text ). lg -- __ | / \ |Leszek Gawron// \\ \_\\ //_/ [EMAIL PROTECTED] _\\()//_ .'/()\'. Phone: +48(501)720812 / // \\ \ \\ // recursive: adj; see recursive | \__/ | - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AW: reading binary stream into xsp page
Marco, On 12 Feb 2004, at 10:41, Marco Rolappe wrote: you can of course have that URL be handled by an XSP that emits the data you get from the db as e.g. a gif image (image/gif), if it was a gif stream. how so I do the above? Do you have any example code I can see? many thanks in advance - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: reading binary stream into xsp page
little correction: you shouldn't do it via an XSP, because XSPs are supposed to be generators, i.e. they must emit SAX events, and have their output serialized by a serializer. you should implement a reader instead, which is supposed to combine those two steps. what it boils down to (when inheriting from AbstractReader) - get your data from the db - know what you're emitting (mime content type) - set the response content type (override getMimeType()) - write the data to the (servlet) output stream (AbstractReader.out) from within generate() I don't have example code at hand, but there must somewhere be a DatabaseReader (cocoon 2.0.4? 2.1.x?), IIRC in the scratchpad. it does more or less what you seem to be wanting. -Ursprungliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Auftrag von beyaRecords - The home Urban music Gesendet: Donnerstag, 12. Februar 2004 11:50 An: [EMAIL PROTECTED] Betreff: Re: AW: reading binary stream into xsp page Marco, On 12 Feb 2004, at 10:41, Marco Rolappe wrote: you can of course have that URL be handled by an XSP that emits the data you get from the db as e.g. a gif image (image/gif), if it was a gif stream. how so I do the above? Do you have any example code I can see? many thanks in advance - 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]
reading binary stream into xsp page
Hi, I have the following code in my xsp page: byte[] binImg = newArt.getArtistPhoto1(); I now want to display this stream in the page like so: xsp:expr>binImg/xsp:expr> but am getting, as expected, casting errors. What do i need to do to display the contents of this stream, which was a simple txt file read into postgresql as a byte array? Any help with this issue will be most appreciated. many thanks in advance
Re: reading binary stream into xsp page
On Thu, 2004-02-12 at 01:48, beyaNet Consultancy wrote: Hi, I have the following code in my xsp page: byte[] binImg = newArt.getArtistPhoto1(); I now want to display this stream in the page like so: xsp:exprbinImg/xsp:expr If this is a textfile try: xsp:exprnew String(binImg)/xsp:expr but am getting, as expected, casting errors. What do i need to do todisplay the contents of this stream, which was a simple txt file readinto postgresql as a byte array? Any help with this issue will be mostappreciated. many thanks in advance -- Eduard Drenth [EMAIL PROTECTED] home sweet home - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]