SoFunction
Updated on 2025-04-05

Display the image generated by JSP in memory to the page

Imaging_ToWeb.jsp

<%@ page autoFlush="false"  import=".*,.*,.*,.*"%>
<%
    String ImageStr = ("ID_Text");
    if(ImageStr==null || (""))
    {
        ("text/html; charset=gb2312");
 %>
<HTML>
 <HEAD>
  <title>Http://</title>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 </HEAD>
 <body>
  <form method="post">
    <input type="text" name=ID_Text>
    <input type=submit value="GO">
  </form>
 </body>
</HTML>

<%
       }
       else
       {
        ();
        ("image/jpeg");
        ("pragma","NO-cache");
        ("Cache-Control","no-cache");
        ("Expries",0);
        int width=300, height=100;
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = ();
//The following fill background color
        ();
        (0, 0, width, height);
        String random="random";
//The following sets the foreground color
        ();
        ("Http://",10,20);
        ("Author:Lion[lion-a@]",10,40);
        (10,50,290,50);
        (ImageStr,10,70);
        ();
        ServletOutputStream outStream = ();
        JPEGImageEncoder encoder =(outStream);
        (image);
        ();
    }

%>