最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > jsp教程

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

日期:11-18    来源:中国设计秀    作者:cnwebshow.com

Imaging_ToWeb.jsp38Z中国设计秀

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

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

%>38Z中国设计秀
 38Z中国设计秀

本文引用地址:/bc/article_46733.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明