将J在内存生成的图片显示到页面_JSP技巧_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

将J在内存生成的图片显示到页面

作者:黑客防线网安JSP教程基地 来源:黑客防线网安JSP教程基地 浏览次数:0

本篇关键词:页面显示图片生成
黑客防线网安网讯:  Imaging_ToWeb.jsp  <%@ page autoFlush="false"  import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>  <%      String ImageStr = request.getPar...

  Imaging_ToWeb.jsp

  <%@ page autoFlush="false"  import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"%>
  <%
      String ImageStr = request.getParameter("ID_Text");
      if(ImageStr==null || ImageStr.equals(""))
      {
          response.setContentType("text/html; charset=gb2312");
   %>
  <HTML>
   <HEAD>
    <title>Http://www.lionsky.net</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
   </HEAD>
   <body>
    <form id="Form1" method="post">
      <input type="text" id="ID_Text" name=ID_Text>
      <input type=submit value="GO">
    </form>
   </body>
  </HTML>

  <%
         }
         else
         {
          out.clear();
          response.setContentType("image/jpeg");
          response.addHeader("pragma","NO-cache");
          response.addHeader("Cache-Control","no-cache");
          response.addDateHeader("Expries",0);
          int width=300, height=100;
          BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
          Graphics g = image.getGraphics();
          //以下填充背景颜色
          g.setColor(Color.lightGray);
          g.fillRect(0, 0, width, height);
          String random="random";
          //以下设置前景色
          g.setColor(Color.BLACK);
          g.drawString("Http://school.cnd8.com",10,20);
          g.drawString("Author:Lion[lion-a@sohu.com]",10,40);
          g.drawLine(10,50,290,50);
          g.drawString(ImageStr,10,70);
          g.dispose();
          ServletOutputStream outStream = response.getOutputStream();
          JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(outStream);
          encoder.encode(image);
          outStream.close();
      }

  %>
  

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-16425-1.html
网站维护教程更新时间:2012-04-07 00:21:34  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer