I want to display a chart (*.jpeg) and HTML-tags (a table filled with values) one a servlet.
The problem is (at least I think this is the problem): you can't use response.setContentType("text/html") and response.setContentType("image/jpeg") together. Is this right?
So how would I get the image into the page?
I thought of something like creating one servlet with content type "image" and one servlet with content type "text" which calls the chart-servlet.
Would this work?
And what would the html-tag to call the image be? Is it the <img> tag?
I made one servlet with response.setContentType("image/jpeg") to create the image. With another servlet with response.setContentType("text/html") I displayed the table and used a <img> tag with the URL of the "image" servlet to display the image.
That's the correct answer except for one thing. The servlet responsible for displaying the page should be replaced with a JSP. (Not incorrect but not a best practice.)
Originally posted by JohannaMos Thanks for the tip!
Its nice to know that somebody cares about things like that!
You're welcome. I guess I care about such things because that's why they pay me the big bucks (yeah, right). Anyway I've found over the years that "best practices" mean easier development, enhancement and maintenance and I'm all about easy.
Bookmarks