servlet异常

05-03-23 Javalga

servlet 调用curve类 代码:

public class CurveServlet extends HttpServlet { public void service(HttpServletRequest re,HttpServletResponse rs){ //Hashtable ht = getFormFieldsHT(re); String param = re.getParameter("reqtype"); //HttpSession session = re.getSession(true); //String strRequestType = (String) ht.get("reqtype"); if (param != null && param.equals("getcurve")) { try{ getcurve(re, rs); }catch(Exception el){ System.out.println("getcurve()"+el.getMessage()); } } System.out.println("service() Success end!!!!!"); } private Hashtable getFormFieldsHT(HttpServletRequest req){ Hashtable ht = new Hashtable(17); String param = null; param = req.getParameter("reqtype"); if (param != null) { ht.put("reqtype", param); } return ht; } private void getcurve(HttpServletRequest re,HttpServletResponse rs){ try{ String minenum = re.getParameter("kbh"); String sensornum = re.getParameter("sensornum"); String startime = re.getParameter("start_date"); String endtime = re.getParameter("end_date"); rs.setContentType("image/gif"); Curve rtd = new Curve(); BufferedImage img = rtd.creatImage(minenum, sensornum, startime, endtime); ServletOutputStream sout = null; try{ sout = rs.getOutputStream(); com.mapinfo.graphics.image.cd cd1=new com.mapinfo.graphics.image. cd(img); cd1.Write(sout); //JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sout); //encoder.encode(img); cd1 = null; }catch(Exception e){ System.out.println("创建图片 错误"+ e.getMessage()); }finally{ //sout.flush(); //sout = null; img.flush(); img = null; } }catch(Exception ex){ System.out.println("CurveServlet 错误"+ ex.getMessage()); }finally{ } }}

SportsBaby1980
2005-03-23 23:27

你贴的什么哪?

不过

看你用JPEGImageEncoder encoder 这个

我想你是用Servlet输出java绘制的图形?

http://www.jsports.org/jive/thread.jspa?forumID=1&threadID=22&tstart=0

这个是我写的。

关于输出图形的

我正在再写一个完整的随机数字图片注册的东西

有兴趣的话可以关注一下