Creating an Dynamic Image using Servlet Output Stream

104 views
Skip to first unread message

naveen krishnan

unread,
Nov 20, 2009, 8:42:47 AM11/20/09
to google-we...@googlegroups.com
Have a question?

Can some one please help me in creating an dynamic Image using the servlet output stream and display it in the GWT client.

I am struck here and not able to proceed further.. This is really urgent..

help is much appreciated...

--
Navaneetha Krishnan .A

rjcarr

unread,
Nov 21, 2009, 7:27:33 PM11/21/09
to Google Web Toolkit
Hi Naveen-

I don't have a ton of time to get all the code right for you, but here
are the basic steps.

1) Create a servlet and correctly specify it in your web.xml.

2) In the doGet() method of your servlet create or open an image.
There are various ways to do this. What you'll likely want to do is
create a buffered image and paint onto the graphics canvas. Flush
this canvas when you're done.

3) Use ImageIO to write your image to the output stream. Something
like: ImageIO.write(image, "png", response.getOutputStream()). Also
make sure you set the correct content type of the response.

4) In gwt make a call to your servlet using the name you specified in
the web.xml: new Image("http://---/servlet"). You can add parameters
or whatever makes sense ... just pick them up with request.getParameter
().

Good luck!
Reply all
Reply to author
Forward
0 new messages