December 30, 2008 at 1:13 AM
Hi friend,
package javacode;
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){
//Set the mime type of the image
res.setContentType("image/jpeg");
try {
// Create an image 200 x 200
BufferedImage bufferedImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_RGB);
//Draw an oval
Graphics g = bufferedImage.getGraphics();
g.setColor(Color.blue);
g.fillOval(0, 0, 199,199);
// Free graphic resources
g.dispose();
ImageIO.write(bufferedImage, "jpg", res.getOutputStream());
}
catch (IOException ioe)
{
System.out.println("error found" + ioe);
}
}
}
------------------------------------------
<servlet>
<servlet-name>imageServlet</servlet-name>
<servlet-class>javacode.ImageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>imageServlet</servlet-name>
<url-pattern>/jsp/ImageServlet</url-pattern>
</servlet-mapping>
-----------------------------------------
Visit for more information.
http://www.roseindia.net/servlers/Thanks.
Related Tutorials/Questions & Answers:
Advertisements
thumbnails - JSP-Servletthumbnails how to create
thumbnails using servlets? Hi friend,
package javacode;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import
java (jquery) - Java Beginners links) the
thumbnails at bottom to be like imageflow (the second links)...
ie. to put a big preview to the image flow which is at bottom as
thumbnails QuickImage 0.2.0 QuickImage 0.2.0
The QuickImage plugin provides an eclipse-editor for viewing images. You can browse images one by one, or all as
thumbnails. Use the toolbar
About PHP GD, WBMP, and XPM etc. We can generate charts,
graphics,
thumbnails, etc. It can do..., arcs etc.
Generate charts, graphics,
thumbnails, etc
It supports
PHP Introduction.
phpThumb
Use this library to generate
thumbnails in your PHP program
how to featch data form db?;';
//+''
+''+'';
$('.
thumbnails').append(li...;'+'</div></li>';
$('.
thumbnails').append(li...;/div></li>';
$('.
thumbnails').append(li