怎样传到客户端去? 文件防到服务器内,客户端通过http联接可以直接获取到文件流。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //用servlet发送图片的例子import java.util.*;import java.text.*;import javax.servlet.*;import javax.servlet.http.*;import java.io.*;import java.net.*;public class ShowImage extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{ this.doPost(req,res); }//doGet public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{ res.setContentType("images/"); String fileName = req.getParameter("IMAGEURL") ; if(fileName==null){ return; } File file = new File("d:/aa.gif"); if(!file.exists()){ return; } FileInputStream is = new FileInputStream(file); OutputStream out = res.getOutputStream(); byte[] buffer = new byte[1024]; int size = -1; while((size = is.read(buffer))!=-1){ out.write(buffer,0,size); }//while out.flush(); out.close(); is.close(); }//doPost Exception in thread "AWT-EventQueue-0" 求电子书 Tcp/ip Sockets in Java 求JBPM的模拟程序...... 如何获得本窗体的大小 .dbf 文件如何打开 新手问题 绘图内容刷新保持的问题 怎样才能用JAVA调用WINDOWS里的CMD 来实现两台机器的连接 自学JAVA,给自己定一个什么设计项目好一点? 高分相送!!在JBuilder 8.0里面怎样用一个应用程序的一个按钮调用另一个应用程序! 数据库连接池问题,在线等待 寻答案
import java.util.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.net.*;public class ShowImage extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{
this.doPost(req,res);
}//doGet public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{
res.setContentType("images/");
String fileName = req.getParameter("IMAGEURL") ;
if(fileName==null){
return;
}
File file = new File("d:/aa.gif");
if(!file.exists()){
return;
}
FileInputStream is = new FileInputStream(file);
OutputStream out = res.getOutputStream();
byte[] buffer = new byte[1024];
int size = -1;
while((size = is.read(buffer))!=-1){
out.write(buffer,0,size);
}//while
out.flush();
out.close();
is.close();
}//doPost