当前位置: 技术问答>java相关
请问:不创建临时文件如何将内容为图片的InputStream显示到HTML页面中?
来源: 互联网 发布时间:2015-04-12
本文导语: 读取了一张图片到InputStream中,不创建临时文件,如何将InputStream中的图片正确显示到HTML页面中呢? | oreilly 的java servlet programming 有提及, 但沒有書在手 看看CODE 吧, ch6, java servlet programming, oreilly...
读取了一张图片到InputStream中,不创建临时文件,如何将InputStream中的图片正确显示到HTML页面中呢?
|
oreilly 的java servlet programming 有提及, 但沒有書在手
看看CODE 吧, ch6, java servlet programming, oreilly
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.oreilly.servlet.ServletUtils;
import Acme.JPM.Encoders.GifEncoder;
public class GraphicalCounter extends HttpServlet {
public static final String DIR = "/images/odometer";
public static final String COUNT = "314159";
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();
Frame frame = null;
Graphics g = null;
try {
// Get the count to display, must be sole value in the raw query string
// Or use the default
String count = (String)req.getQueryString();
if (count == null) count = COUNT;
int countlen = count.length();
Image images[] = new Image[countlen];
for (int i = 0; i
看看CODE 吧, ch6, java servlet programming, oreilly
import java.awt.*;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.oreilly.servlet.ServletUtils;
import Acme.JPM.Encoders.GifEncoder;
public class GraphicalCounter extends HttpServlet {
public static final String DIR = "/images/odometer";
public static final String COUNT = "314159";
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
ServletOutputStream out = res.getOutputStream();
Frame frame = null;
Graphics g = null;
try {
// Get the count to display, must be sole value in the raw query string
// Or use the default
String count = (String)req.getQueryString();
if (count == null) count = COUNT;
int countlen = count.length();
Image images[] = new Image[countlen];
for (int i = 0; i