<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆 - 37  文章 - 14  trackbacks - 0
    <2009年12月>
    293012345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章分類

    相關鏈接

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    今天利用JFreeChart結合DWR ReverseAjax實現服務器數據“推”到客戶端;在客戶端用JFreeChart默認的org.jfree.chart.servlet.DisplayChart
    顯示圖片,會出現不同的客戶端不能顯示圖片;查看DisplayChart源碼
     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");
            }

            
    //  Replace ".." with ""
            
    //  This is to prevent access to the rest of the file system
            filename = ServletUtilities.searchReplace(filename, "..""");

            
    //  Check the file exists
            File file = new File(System.getProperty("java.io.tmpdir"), filename);
            
    if (!file.exists()) {
                
    throw new ServletException("File '" + file.getAbsolutePath() 
                        
    + "' does not exist");
            }

            
    //  Check that the graph being served was created by the current user
            
    //  or that it begins with "public"
            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(06).equals("public")) {
                    isChartPublic 
    = true;
                }
            }

            
            
    boolean isOneTimeChart = false;
            
    if (filename.startsWith(ServletUtilities.getTempOneTimeFilePrefix())) {
                isOneTimeChart 
    = true;   
            }

            
    if (isChartInUserList || isChartPublic || isOneTimeChart) {
                
    //  Serve it up
                ServletUtilities.sendTempFile(file, response);
                
    if (isOneTimeChart) {
                    file.delete();   
                }
            }
            
    else {
                
    throw new ServletException("Chart image not found");
            }
            
    return;
        }
    其中無法顯示的圖片的原因跟 isChartInUserList || isChartPublic || isOneTimeChart 有關;其中isChartInUserList是為同一session,因服務器推是同時推向多客戶端,這個isChartInUserList為false是沒法改變;isOneTimeChart是在創建chart的時候,如果session為null則會記錄該chart為one-time use,顯示一次后會被刪除;因此想從isChartPublic入手了;但是JFreeChart API并沒發現提供如何產生public+filename的chart;因此重寫DisplayChart默認為public,這樣所有的客戶端都可以顯示。





    posted on 2008-09-09 17:26 扭曲的鉛筆 閱讀(944) 評論(1)  編輯  收藏 所屬分類: J2EE

    FeedBack:
    # re: JFreeChart顯示 2009-12-18 14:57 songkewei
    能不能把你的源代碼發給我讓我學習一下,謝謝,謝謝!
    songkewei110@126.com  回復  更多評論
      
    主站蜘蛛池模板: 热99re久久免费视精品频软件| 三年片在线观看免费观看大全动漫| 国产92成人精品视频免费| 国产精品亚洲精品| 亚洲乱色伦图片区小说| 91香蕉视频免费| 亚洲av无码一区二区三区天堂古代| 亚洲久热无码av中文字幕| 免费无码又黄又爽又刺激| 亚洲欧美aⅴ在线资源| 国产男女猛烈无遮挡免费视频网站 | 国产VA免费精品高清在线| 亚洲综合亚洲综合网成人| 国产一区二区三区免费观在线| 亚洲精品无码不卡在线播HE| 男人都懂www深夜免费网站| 在线a毛片免费视频观看| 精品国产综合成人亚洲区| 久久免费国产视频| 亚洲天堂一区在线| 成人无遮挡裸免费视频在线观看 | 亚洲国产香蕉人人爽成AV片久久 | 亚洲午夜成人精品无码色欲| 国产大片91精品免费观看男同 | 亚洲专区一路线二| 国产无遮挡吃胸膜奶免费看 | 免费大黄网站在线观| 中文字幕不卡高清免费| 久久精品国产亚洲AV香蕉| 四虎成人免费网址在线| 好吊色永久免费视频大全| 国产一区二区三区免费视频| 中文字幕免费播放| 亚洲制服在线观看| 亚洲第一区在线观看| 日本亚洲欧洲免费天堂午夜看片女人员 | 亚洲妇女水蜜桃av网网站| 国产午夜无码视频免费网站| 国产成人久久AV免费| 亚洲AV永久无码精品放毛片| 日本红怡院亚洲红怡院最新|