- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- public class ServletDemo2 extends HttpServlet {
- private static final int WIDTH=125;
- private static final int HEIGHT=25;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- BufferedImage image=new BufferedImage(WIDTH,HEIGHT,BufferedImage.TYPE_INT_RGB);
-
- Graphics g=image.getGraphics();
- setBackground(g);
- drawBorder(g);
- drawRandomLines(g);
- drawRandomNum(g);
-
- response.setContentType("image/jpeg");
- ImageIO.write(image, "jpg", response.getOutputStream());
-
- }
复制代码 页面根本不能打开,为什么呢啊,求解答,是浏览器的问题吗,我用ie和360都不行 |
|