<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

    常用鏈接

    留言簿

    隨筆分類

    隨筆檔案

    文章分類

    相關(guān)鏈接

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    今天利用JFreeChart結(jié)合DWR ReverseAjax實(shí)現(xiàn)服務(wù)器數(shù)據(jù)“推”到客戶端;在客戶端用JFreeChart默認(rèn)的org.jfree.chart.servlet.DisplayChart
    顯示圖片,會出現(xiàn)不同的客戶端不能顯示圖片;查看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 有關(guān);其中isChartInUserList是為同一session,因服務(wù)器推是同時推向多客戶端,這個isChartInUserList為false是沒法改變;isOneTimeChart是在創(chuàng)建chart的時候,如果session為null則會記錄該chart為one-time use,顯示一次后會被刪除;因此想從isChartPublic入手了;但是JFreeChart API并沒發(fā)現(xiàn)提供如何產(chǎn)生public+filename的chart;因此重寫DisplayChart默認(rèn)為public,這樣所有的客戶端都可以顯示。





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

    FeedBack:
    # re: JFreeChart顯示 2009-12-18 14:57 songkewei
    能不能把你的源代碼發(fā)給我讓我學(xué)習(xí)一下,謝謝,謝謝!
    songkewei110@126.com  回復(fù)  更多評論
      
    主站蜘蛛池模板: a高清免费毛片久久| 亚洲av最新在线观看网址| 亚洲Av无码专区国产乱码DVD | 成年女性特黄午夜视频免费看| 色播在线永久免费视频| 亚洲国产精品嫩草影院久久| 亚洲AV无码专区国产乱码电影 | 免费无码av片在线观看| 69堂人成无码免费视频果冻传媒| 免费欧洲美女牲交视频| 亚洲∧v久久久无码精品| 亚洲jizzjizz少妇| 免费播放特黄特色毛片| 国产成人精品日本亚洲专 | 中出五十路免费视频| 毛片免费在线观看网站| 亚洲日韩精品国产3区| 99热在线精品免费播放6| 亚洲国产免费综合| 亚洲视频在线视频| 猫咪免费观看人成网站在线| 亚州免费一级毛片| 亚洲国产精品一区二区久久hs| 亚洲变态另类一区二区三区| 大胆亚洲人体视频| 亚洲人成网站在线播放2019| 波多野结衣免费视频观看| EEUSS影院WWW在线观看免费| 亚洲AV日韩AV永久无码绿巨人| 免费下载成人电影| 亚洲视频一区二区在线观看| 无遮挡免费一区二区三区| 成人AV免费网址在线观看| 亚洲精品自在线拍| 免费无码成人AV在线播放不卡| 亚洲成a人片在线看| 亚洲日韩在线第一页| 免费高清A级毛片在线播放| 国产美女a做受大片免费| 亚洲欧美不卡高清在线| 亚洲中文字幕无码中文字在线|