(Source Code) Creating Images in a Java Servlet
Source Code : Creating Images in a Java Servlet
Dynamic images are commonly used in web applications. You will find dynamic images such as charts, captcha, web site thumbnails, image thumbnails, watermarks, etc. This tutorial will give you a brief walk through on creating a simple dynamic image in a Java Servlet.
Setting up the Servlet
As with most servlets, this servlet will override the doGet() method in HttpServlet. The doGet() method will be called when an HTTP GET request is made to the servlet. We can expect an HTTP GET request when a servlet is called within an <img> tag.
view plaincopy to clipboardprint?
- package com.codebeach.servlet;
- import java.io.*;
- import javax.servlet.*;
- import javax.servlet.http.*;
- import java.awt.*;
- import java.awt.image.*;
- import javax.imageio.*;
- public class ImageServlet extends HttpServlet
- {
- public void doGet(HttpServletRequest req,
- HttpServletResponse res)
- {
- }
- }
Courtesy:- codebeach.com
- guru's blog
- Login to post comments
