Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

thumbnails

Ads

 
 

Share on Google+Share on Google+

suresh
thumbnails
1 Answer(s)      8 years ago
Posted in : JSP-Servlet
Ads
View Answers

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.

Ads









Related Tutorials/Questions & Answers:
thumbnails - JSP-Servlet
thumbnails  how to create thumbnails using servlets?  Hi friend, package javacode; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.awt.*; import
Eclipse Plunging-Graphics
by one, or as thumbnails. Use the toolbar to navigate or by single- or double
Advertisements
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.... Generate charts, graphics, thumbnails, etc It supports different image formats
How to use flickr image in Flex
smoothing to true on the images so the thumbnails don?t look as pixelated
Displaying images using Javascript
="strip_of_thumbnails">   <div>  ...;class="strip_of_thumbnails">   <div><a href...;   <div class="strip_of_thumbnails">   <
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
ActionScriptTutorials
that will be used as our thumbnails. We also created larger .swf movies for each
Python Programming Books
processing applications. You can use the library to create thumbnails, convert