开发者

Java HTML rendering using Cobra

开发者 https://www.devze.com 2023-02-08 18:24 出处:网络
I am currently using Cobra: Java HTML Renderer & Parser to render an HTML page that is dynamically gener开发者_StackOverflow社区ated based on user choices in a java app.

I am currently using Cobra: Java HTML Renderer & Parser to render an HTML page that is dynamically gener开发者_StackOverflow社区ated based on user choices in a java app.

In my app the user has a choice of hundreds of items to select. The items are displayed in the form of special uniquely colored symbols and the user can select more then one item.

Once a number of items are selected their written description is dynamically generated and formatted to include css2 and html4 tags and loaded into the Cobra HTMLPanel for display.

I wish to display the image of the symbol with the written description of an item in the HTMLPanel.

One way to do this would be to save the BufferedImage to a file using ImageIO.write and then include the img html tag in my dynamically generated HTML document that is being loaded into HTMLPanel. Unfortunately this is unacceptable as there may be hundreds of symbols being selected by the user wich in turn would result in hundreds of ImageIO.write calls and an incredible decrease in performance of my app.

An alternate way would be to convert the BufferedImage to a Base64 encoding and then directly place the encoding into the HTML document as follows

<img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />

Unfortunately HTMLPanel appears to ignore the data URI scheme.

Does anyone know a solution?


Use an embedded servlet container like Jetty. Point the URLs to "http://localhost:somePort/imageId", and then serve those URLs up from memory.

0

精彩评论

暂无评论...
验证码 换一张
取 消