練功房推薦書單

  • Google!Android 3手機應用程式設計入門(第四版)
  • 賈伯斯傳(軟皮精裝版)
  • 猛虎出閘制霸版:最新OCP Java SE 6 Programmer專業認證(附原始程式碼及範例檔)
  • SCWCD 5 猛虎出閘:Java Web 應用程式專業認證
Messages posted by: andowson
Forum Index » Profile for andowson » Messages posted by andowson
Message
mylipton wrote:andowson 您好
我把ISO-88591-1 後面的UTF-8 改成big5之後可以下載中文檔名的檔案了,
但很奇怪,如果我把路徑"/WEB-INF/export" 改成別的路徑,就又會出現File not found

這是設計上的問題,這個下載程式為了安全起見,將所要要下載的檔案都放在WEB-INF/export目錄下,您可以配合需要更改設計。例如您可以改為將檔案都放在WEB-INF/download目錄下,則程式中就應改為WEB-INF/download。
mylipton您好:
我今天測試了一下,發現不同的瀏覽器對於中文檔名直接輸入在網址列的處理有點不同,Google Chrome會自動把中文字改為UTF-8編碼,IE和Firefox則不會。
以下是我的測試方法,供您參考:
1.在WEB-INF/export目錄下手動產生一個文字檔,名稱就叫做「新增文字文件.txt」
2.在網址列上直接輸入:
http://localhost:8080/examples/download.jsp?file=新增文字文件.txt
修改後的程式碼如下:
<%@ page import= "java.io.*" %>
<%!
     private static final int BUFSIZE = 2048;
	  /**
     *  Sends a file to the ServletResponse output stream.  Typically
     *  you want the browser to receive a different name than the
     *  name the file has been saved in your local database, since
     *  your local names need to be unique.
     *
     *  @param request The request
     *  @param response The response
     *  @param filename The name of the file you want to download.
     *  @param original_filename The name the browser should receive.
     */
    private void doDownload( HttpServletRequest request, HttpServletResponse response,
                             String filename, String original_filename )
        throws IOException
    {
        File                f        = new File(filename);
        int                 length   = 0;
        ServletOutputStream op       = response.getOutputStream();
        ServletContext      context  = getServletConfig().getServletContext();
        String              mimetype = context.getMimeType( filename );

        //
        //  Set the response and go!
        //
        //
        response.setContentType( (mimetype != null) ? mimetype : "application/octet-stream" );
        response.setContentLength( (int)f.length() );
        response.setHeader( "Content-Disposition", "attachment; filename=\"" + original_filename + "\"" );

        //
        //  Stream to the requester.
        //
        byte[] bbuf = new byte[BUFSIZE];
        DataInputStream in = new DataInputStream(new FileInputStream(f));

        while ((in != null) && ((length = in.read(bbuf)) != -1))
        {
            op.write(bbuf,0,length);
        }

        in.close();
        op.flush();
        op.close();
    }
%>
<%
	String original_filename = request.getParameter("file");
    String target_filename = "";
    
    // Chrome will auto escape the URL characters
    String userAgent = request.getHeader("user-agent");
    System.out.println(userAgent);
    String charset = "MS950";
    if (userAgent.indexOf("Chrome") != -1) {
    	charset = "UTF-8";
    }

    // Security Isuue: User can type file=../WEB-INF/web.xml
    //String filename = application.getRealPath(original_filename);
    boolean error = false;
    if (original_filename != null && !"".equals(original_filename.trim()) && !original_filename.startsWith("../")) {
    	target_filename = new String(original_filename.getBytes("ISO-8859-1"), charset);
    	String filename = application.getRealPath("/")+"WEB-INF/export/" + target_filename;
    	File file = new File(filename);	
    	if (file.exists()) {
    	    doDownload(request, response, filename, original_filename);
    	    // delete the file after download
    	    //boolean deleted = file.delete();
    	    //System.out.println("File " + target_filename + " deleted: " + deleted);
    	} else {
    		error = true;
    	}
    } else {
    	error = true;
    }
    if (error) {
    	response.setContentType("text/html; charset=UTF-8");
		out.println("File not found: " + target_filename);
    }
%>

mylipton您好:
要下載中文檔名的檔案也很簡單,只要將傳數的參數加以轉換編碼即可。
<%@ page import= "java.io.*" %>
<%!
     private static final int BUFSIZE = 2048;
	  /**
     *  Sends a file to the ServletResponse output stream.  Typically
     *  you want the browser to receive a different name than the
     *  name the file has been saved in your local database, since
     *  your local names need to be unique.
     *
     *  @param request The request
     *  @param response The response
     *  @param filename The name of the file you want to download.
     *  @param original_filename The name the browser should receive.
     */
    private void doDownload( HttpServletRequest request, HttpServletResponse response,
                             String filename, String original_filename )
        throws IOException
    {
        File                f        = new File(filename);
        int                 length   = 0;
        ServletOutputStream op       = response.getOutputStream();
        ServletContext      context  = getServletConfig().getServletContext();
        String              mimetype = context.getMimeType( filename );

        //
        //  Set the response and go!
        //
        //
        response.setContentType( (mimetype != null) ? mimetype : "application/octet-stream" );
        response.setContentLength( (int)f.length() );
        response.setHeader( "Content-Disposition", "attachment; filename=\"" + original_filename + "\"" );

        //
        //  Stream to the requester.
        //
        byte[] bbuf = new byte[BUFSIZE];
        DataInputStream in = new DataInputStream(new FileInputStream(f));

        while ((in != null) && ((length = in.read(bbuf)) != -1))
        {
            op.write(bbuf,0,length);
        }

        in.close();
        op.flush();
        op.close();
    }
%>
<%
	String original_filename = request.getParameter("file");
    String target_filename = ""; 

    // Security Isuue: User can type file=../WEB-INF/web.xml
    //String filename = application.getRealPath(original_filename);
    boolean error = false;
    if (original_filename != null && !"".equals(original_filename.trim()) && !original_filename.startsWith("../")) {
    	target_filename = new String(original_filename.getBytes("ISO-8859-1"), "MS950");
    	String filename = application.getRealPath("/")+"WEB-INF/export/" + target_filename;
    	File file = new File(filename);	
    	if (file.exists()) {
    	    doDownload(request, response, filename, original_filename);
    	    // delete the file after download
    	    //boolean deleted = file.delete();
    	    //System.out.println("File " + target_filename + " deleted: " + deleted);
    	} else {
    		error = true;
    	}
    } else {
    	error = true;
    }
    if (error) {
    	response.setContentType("text/html; charset=MS950");
		out.println("File not found: " + target_filename);
    }
%>
這是今天無意中發現的

smilie 遠傳電信 S 市集討論區
http://www.smartapp.tw/aps/App/jforum.action
成立日期:2010/01/05
討論區版本:JForum 2.1.8
作業系統:Solaris
網頁伺服器:Apache/2.2.8
應用伺服器:WebLogic
在公司內部網路OA的環境禁止直接連線到Internet,必須透過Proxy才能上網,如果要安裝伺服器,先前寫的那些shell script都是使用wget自動去網路抓檔案回來安裝,如果能讓wget可以透過proxy去抓檔案,則原本的shell script就可以照著執行了。

要讓wget透過proxy去抓檔案在Linux下很簡單,以下是我找到的一個最方便的設定方式:
編輯 /etc/wgetrc
加上
http_proxy = http://10.160.3.88:8080/
use_proxy = on


參考資料
http://mis.ntct.edu.tw/book/368

另外因很多shell script有用到yum,也可以參考一下這篇yum的proxy設定
http://www.andowson.com/posts/list/183.page
mylipton您好:
請問您是在什麼系統環境下執行所產生的問題? 請您提供更多資訊以便大家可以較快得幫忙您。例如
OS版本:
Servlet Container版本:
JDK版本:
上傳前檔案名稱:
上傳後檔案名稱:
參考資料:附上錯誤畫面及有錯誤的程式原始碼。
另外也請您參考本篇文章先前的討論內容尋找解答。
★報名期間:99 年 6 月 4 日至 6 月 18 日(下午18:00)截止,逾期恕不受理。

★報名方式:採網路報名外,另請郵寄相關應繳資料。

★徵才公告:http://www.cht.com.tw/CompanyCat.php?CatID=4&NewsID=4070&Page=HotNewsDetail

★報名網址:https://rmis.cht.com.tw/portal/hrms/pre_login.jsp

自從五月初轉移到Linode後,帳單陸續來了,現在就來檢視一下五月份實際的費用支出狀況吧。

Linode VPS 我是刷信用卡付款的,結果還要多收一條「國外交易手續費」
LINODE.COM NT$ 625 (=US$ 19.95)
國外交易手續費 NT$ 13
這樣子總共是638元

電費的部份,上一期的帳單金額是2,213元,這一期則是1,545元
節省了:2213元-1545元=668元

兩個金額相比起來,638元 < 668元=>花的錢比省下來的錢還要少,看來還算滿划算的。

有興趣租個VPS的人可以按下面的連結申請:
http://www.linode.com/?r=60f84faceb69fc66af4c0be8c8ffe68754b2ac58
jonathan1977您好:
我查了一下,您的網域並未設定MX record,請參考下列網址:
http://www.robtex.com/dns/c123.tw.html#records
建議您還是先完成我之前說的DNS設定,再繼續。
jonathan1977您好:
請問您有設定DNS嗎?目前去PING該網域名稱是解析不出來的:
C:\Users\Andowson>ping mail.c123.tw
Ping 要求找不到主機 mail.c123.tw。請檢查名稱,然候再試一次。

請到您當初申請網域名稱的廠商那邊去設定一下DNS(HOST/IP)資料。
dingjun您好:
提醒您一下,install不是目錄,請改用類似下面的網址進行安裝的動作(沒有最後的斜線/)
http://localhost:5080/openmeetings/install
請再試一下。
dingjun您好:
底下是我的OpenMeetings安裝目錄及內容,您可以發現並沒有所謂的installer目錄
[andowson@www ~]$ cd /var/red5
[andowson@www red5]$ ll
總計 2500
-rw-r--r-- 1 root root  16033  5月 21 00:01 boot.jar
drwxr-xr-x 3 root root   4096  5月 21 00:01 conf
drwxr-xr-x 2 root root   4096  5月 21 00:01 lib
-rw-r--r-- 1 root root   1472  5月 21 00:01 license.txt
drwxr-xr-x 2 root root   4096  6月  3 03:49 log
-rw------- 1 root root 485251  6月  3 03:50 nohup.out
-rw-r--r-- 1 root root   1107  5月 21 00:01 red5.bat
-rw-r--r-- 1 root root    167  5月 21 00:01 red5-debug.bat
-rwxr-xr-x 1 root root    220  5月 21 00:01 red5-debug.sh
-rw-r--r-- 1 root root   1193  5月 21 00:01 red5-highperf.bat
-rwxr-xr-x 1 root root    437  5月 21 00:01 red5-highperf.sh
-rw-r--r-- 1 root root 996012  5月 21 00:01 red5.jar
-rwxr-xr-x 1 root root   1297  5月 21 00:01 red5.sh
-rw-r--r-- 1 root root    303  5月 21 00:01 red5-shutdown.bat
-rwxr-xr-x 1 root root    344  5月 21 00:01 red5-shutdown.sh
-rw-r--r-- 1 root root 984064  5月 21 00:01 src.zip
drwxr-xr-x 4 root root   4096  5月 21 00:01 webapps
drwxr-xr-x 4 root root   4096  5月 21 22:50 work
[andowson@www red5]$ cd webapps/
[andowson@www webapps]$ ll
總計 12
drwxr-xr-x 16 root root 4096  5月 21 00:03 openmeetings
-rw-r--r--  1 root root 1884  5月 21 00:01 red5-default.xml
drwxr-xr-x  3 root root 4096  5月 21 00:01 root
[andowson@www webapps]$ cd openmeetings/
[andowson@www openmeetings]$ ll
總計 3740
drwxr-xr-x 6 root root    4096  5月 21 00:01 axis2-web
-rw-r--r-- 1 root root  177080  5月 21 00:01 broadcast.lzx.lzr=swf8.swf
drwxr-xr-x 2 root root    4096  5月 21 22:49 conf
-rw-r--r-- 1 root root    8745  5月 21 00:01 config.xml
drwxr-xr-x 2 root root    4096  5月 21 00:01 default
drwxr-xr-x 2 root root    4096  5月 21 00:01 desktop
-rw-r--r-- 1 root root   44284  5月 21 00:01 embed-compressed.js
-rw-r--r-- 1 root root    2462  5月 21 00:01 favicon.ico
-rw-r--r-- 1 root root    3485  5月 21 00:01 index.jsp
drwxr-xr-x 3 root root    4096  5月 21 00:01 jod
drwxr-xr-x 2 root root    4096  5月 21 00:01 languages
-rw-r--r-- 1 root root    1068  5月 21 00:01 license.txt
-rw-r--r-- 1 root root 2098406  5月 21 00:03 maindebug.swf8.swf
-rw-r--r-- 1 root root 1057073  5月 21 00:03 main.swf8.swf
-rw-r--r-- 1 root root   11336  5月 21 00:01 openmeetings_licence.txt
drwxr-xr-x 3 root root    4096  5月 21 00:01 public
-rw-r--r-- 1 root root     847  5月 21 00:01 rawSOAP.xml
-rw-r--r-- 1 root root     340  5月 21 00:01 Red5.bat
drwxr-xr-x 2 root root    4096  5月 21 00:04 red5-screenshare
drwxr-xr-x 2 root root    4096  5月 21 00:04 screen
drwxr-xr-x 2 root root    4096  5月 21 00:01 sip-applet
drwxr-xr-x 3 root root    4096  5月 21 00:01 streams
-rw-r--r-- 1 root root  322539  5月 21 00:01 subscribe.lzx.lzr=swf8.swf
drwxr-xr-x 5 root root    4096  5月 22 09:55 upload
drwxr-xr-x 4 root root    4096  5月 22 09:55 uploadtemp
drwxr-xr-x 8 root root    4096  5月 21 00:01 WEB-INF

如果您觀察一下WEB-INF/web.xml中可以看到,OpenMeetings有一個Servlet叫做install(注意沒有er)
    <servlet>
        <servlet-name>Install</servlet-name>
        <servlet-class>org.openmeetings.servlet.outputhandler.Install</servlet-class>
    </servlet>
    ...
    <servlet-mapping>
        <servlet-name>Install</servlet-name>
        <url-pattern>/Install</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Install</servlet-name>
        <url-pattern>/install</url-pattern>
    </servlet-mapping>

所以安裝時您應該存取的應該是類似下列這樣的網址才對:
http://localhost:5080/openmeetings/install
jonathan1977您好:

請參考鳥哥的 Linux 私房菜
http://linux.vbird.org/linux_server/0380mail.php

或是購買
鳥哥的Linux私房菜基礎學習篇第二版(附光碟)
image
中華電信股份有限公司99年遴選新進從業人員 公告

主旨:公告本公司電信研究所暨企業客戶分公司99年遴選新進從業人員事宜。
依據:中華電信股份有限公司99年5月27日信人一字第0990000642號函辦理。

公告事項:

壹、 遴選日程:
  一、報名日期:99 年 5 月 28 日 9:00 至 99 年 6 月 9 日 24:00
  二、第一試(資歷論文審查)日期:99 月 6 月 10 日至 99 年 6 月 14 日由本公司電信研究所
    及企業客戶分公司資歷審查小組上網遴選
  三、第二試通知日期:99 年 6 月 15 日 14:00(電信研究所網站公告外,詳細口試時程另
    行 mail 通知)
  四、第二試(口試)日期:99 年 6 月 19 日至 99 年 6 月 20 日(若有異動,以通知變更日期
    為準)
  五、放榜日期:99 年 6 月 23 日(若有異動,以通知變更日期為準)

採網路報名:http://202.39.164.13/pr/

詳情請參考附件內容或下列網址:
http://www.cht.com.tw/CompanyCat.php?CatID=4&NewsID=4063&Page=HotNewsDetail
今天發現CentOS 5.5已經於2010/05/14釋出了

釋出消息
http://lists.centos.org/pipermail/centos-announce/2010-May/016638.html

下載(DVD iso)
http://ftp.tcc.edu.tw/Linux/CentOS/5/isos/

參考資料:
http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=18237
 
Forum Index » Profile for andowson » Messages posted by andowson
Go to: