首先你得先知道ServletUtilities这个类是怎么实现的,里面的几个方法要知道是什么用途,现在这段程序,看不出来是干什么的。首先是取得一个Parameter(filename),然后调用
ServletUtilities.searchReplace初步处理一下这个参数,然后建立文件判断文件是否存在,..........这样说起来真没有什么意义,你还是看看全文再说吧,这太片段了

解决方案 »

  1.   

    全文如下:
    package jinghua.chart.servlet;import java.io.File;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import jinghua.JinghuaConn;// Referenced classes of package jinghua.chart.servlet:
    //            ChartDeleter, ServletUtilitiespublic class DisplayChart extends HttpServlet
    {    public DisplayChart()
        {
        }    public void init()
            throws ServletException
        {
        }    public void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException
        {
            HttpSession session = request.getSession();
            String filename = request.getParameter("filename");
            if(filename == null)
                throw new ServletException("Parameter 'filename' must be supplied");
            filename = ServletUtilities.searchReplace(filename, "..", "");
            File file = new File(JinghuaConn.getChartPath(), filename);
            if(!file.exists())
                throw new ServletException("File '" + file.getAbsolutePath() + "' does not exist");
            boolean isChartInUserList = false;
            ChartDeleter chartDeleter = (ChartDeleter)session.getAttribute("JFreeChart_Deleter");
            if(chartDeleter != null)
                isChartInUserList = chartDeleter.isChartAvailable(filename);
            boolean isChartPublic = false;
            if(filename.length() >= 6)
            {
                if(filename.substring(0, 6).equals("public"))
                    isChartPublic = true;
            }
            if(isChartInUserList || isChartPublic)
                ServletUtilities.sendTempFile(file, response);
            else
                throw new ServletException("Chart image not found");
        }
    }谢谢大家
      

  2.   

    DisplayChart这个名字好熟悉
    是jfreechart包中的一个servlet负责生成图文件jfreechart是一个对报表生成图形显示的工具
      

  3.   

    这好像是JFreeChart的东西,具体不清楚
    大概是根据参数取得一个文件,在从中取得需要的数据,从信息来看好像是:Chart image