Hi ponkoj,

Here I am giving u a lil program which generates JPEG image on the fly.
However, you need to write your own routines for reading data from
database(whatever you want), generate images from the data read from the
databse. This lil program draws a rectangle and an oval and converts them
into JPEG image, and encodes JPEG image.

Hope it helps u.


 import com.sun.image.codec.jpeg.*;
public class JPEGServlet extends HttpServlet {
                               //Process the HTTP Get request
                               public void doGet(HttpServletRequest
request, HttpServletResponse response)
                                  throws    ServletException, IOException
{
                                   response.setContentType("image/jpeg");
                                   ServletOutputStream out =
response.getOutputStream();
                                   BufferedImage image = new
BufferedImage(100,100, BufferedImage.TYPE_INT_RGB);
                                   Graphics g = image.getGraphics();
                                   g.setColor(Color.green);
                                   g.fillRect(0, 0, 100, 100);
                                   g.setColor(Color.red);
                                   g.drawOval(0, 0, 100,100);
                                   JPEGImageEncoder encoder
=JPEGCodec.createJPEGEncoder(out);
                                   encoder.encode(image);
                                   out.close();
                               }
                               //Process the HTTP Post request
                               public void doPost(HttpServletRequest
request, HttpServletResponse response)
                                   throws ServletException, IOException {
                                   doGet(request,response);
                               }
                           }




                        *************************
                        *                       *
                        *  A.S.M. Rokanuzzaman  *
                        *  Computer Science     *
                        *  UND                  *
                        *  Phone:701-777-9352   *
                        *                       *
                        *************************

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to