atnatn
atnatn

Reputation: 238

Display a Graphics2D as JPG in JSP

Is it possible to use Graphics2D in a servlet?

And if I have a Graphics2D object, is it possible for me to convert it to a .jpg image and display it in a JSP page?

Upvotes: 0

Views: 1093

Answers (2)

trashgod
trashgod

Reputation: 205865

JFreeChart has a good example of doing this. To accommodate older versions, it provides a org.jfree.chart.encoders.SunJPEGEncoderAdapter. The encode() method shows how to use ImageIO for either byte array or stream.

Upvotes: 1

Asad Rasheed
Asad Rasheed

Reputation: 518

In my opinion yes, Read the link for better understanding.

Upvotes: 1

Related Questions