You need to host the file on some kind of server and transmit it via JSP or Servlets. Have you set up a Java or J2EEservlet before? I'd download and try Tomcat out, then try some JSP writing tutorials. Once you've got that covered you can output the string buffer data pretty easily.
Alternatively, if you have a non-java server you could have the java program generate the string buffer as an HTML file that the server than serves but this solution isn't usually very useful especially if the file changes based on certain inputs like user information/state.
You should try to be more forthcoming with information, rather than mentioning things like "jsf" in passing! If you are indeed using JSF, I would have a backing bean expose a property of type String and then just access that string, for example: In your backing bean class, you can implement this any way you like, for example, with a StringBuffer: [ November 21, 2005: Message edited by: Jeff Albrechtsen ]
Remember that you are generating a page that can be interpreted by a browser. And browsers can't interpret pages that contain mixtures of text and binary data like images. When web designers want to "include" an image in a page, they do that by putting an <img> element in their page with a link to the image. They don't put the image itself into the page.
So you will have to do the same thing. If you are generating the image dynamically then your HTML will have to have an <img> element whose "src" attribute is a link to something (I would use a servlet) that returns only the binary data and nothing else.
Joined: Sep 16, 2005
If you are indeed using JSF, why not just use h:graphicImage?
Joined: Nov 02, 2005
I am not displaying image from any particular location. The image I am getting is from IBM Content Manager. It has some java API. Using those API's the only way i can display images is using byte array. For a single page it works fine. Since need to display more pages used String buffer to append. Now wants to convert this StringBuffer into byte array so that i can display it in the browser.
Sorry for the confusion. Thanks.
Joined: Sep 16, 2005
Finally! You've explained your context! Again, html use the <img> tag to embed images:
Different web frameworks have their own tags to generate that html.
The typical bare-bones servlet/jsp solution is to map such paths to a servlet that writes back the image. Any textbook on servlets/jsps will have an example of that.
Now, it would be great if JSF had some way to bind a property to simplify this, but I haven't seen that done. Anybody?