www.亚洲色图.com,亚洲七久久之综合七久久,精品国产_亚洲人成在线高清http://www.tkk7.com/askcuix/category/32218.htmlKeep Walking......zh-cnMon, 07 Mar 2011 20:55:26 GMTMon, 07 Mar 2011 20:55:26 GMT60SAXParseException: Content is not allowed in prologhttp://www.tkk7.com/askcuix/archive/2011/03/07/345896.htmlChris.CuiChris.CuiMon, 07 Mar 2011 10:39:00 GMThttp://www.tkk7.com/askcuix/archive/2011/03/07/345896.htmlhttp://www.tkk7.com/askcuix/comments/345896.htmlhttp://www.tkk7.com/askcuix/archive/2011/03/07/345896.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/345896.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/345896.html
出現(xiàn)這種問題,有幾種可能性:  閱讀全文

Chris.Cui 2011-03-07 18:39 發(fā)表評論
]]>
使用ARA實現(xiàn)GlassFish中Web應(yīng)用的資源分配http://www.tkk7.com/askcuix/archive/2010/04/23/319210.htmlChris.CuiChris.CuiFri, 23 Apr 2010 09:55:00 GMThttp://www.tkk7.com/askcuix/archive/2010/04/23/319210.htmlhttp://www.tkk7.com/askcuix/comments/319210.htmlhttp://www.tkk7.com/askcuix/archive/2010/04/23/319210.html#Feedback2http://www.tkk7.com/askcuix/comments/commentRss/319210.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/319210.html閱讀全文

Chris.Cui 2010-04-23 17:55 發(fā)表評論
]]>
GlassFish移植Tipshttp://www.tkk7.com/askcuix/archive/2010/03/23/316339.htmlChris.CuiChris.CuiTue, 23 Mar 2010 09:30:00 GMThttp://www.tkk7.com/askcuix/archive/2010/03/23/316339.htmlhttp://www.tkk7.com/askcuix/comments/316339.htmlhttp://www.tkk7.com/askcuix/archive/2010/03/23/316339.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/316339.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/316339.html閱讀全文

Chris.Cui 2010-03-23 17:30 發(fā)表評論
]]>
GlassFish Componentshttp://www.tkk7.com/askcuix/archive/2009/12/21/306820.htmlChris.CuiChris.CuiMon, 21 Dec 2009 08:40:00 GMThttp://www.tkk7.com/askcuix/archive/2009/12/21/306820.htmlhttp://www.tkk7.com/askcuix/comments/306820.htmlhttp://www.tkk7.com/askcuix/archive/2009/12/21/306820.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/306820.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/306820.html閱讀全文

Chris.Cui 2009-12-21 16:40 發(fā)表評論
]]>
StartUp Choice: ServletContextListener vs Servlethttp://www.tkk7.com/askcuix/archive/2009/11/03/300894.htmlChris.CuiChris.CuiTue, 03 Nov 2009 06:46:00 GMThttp://www.tkk7.com/askcuix/archive/2009/11/03/300894.htmlhttp://www.tkk7.com/askcuix/comments/300894.htmlhttp://www.tkk7.com/askcuix/archive/2009/11/03/300894.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/300894.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/300894.html閱讀全文

Chris.Cui 2009-11-03 14:46 發(fā)表評論
]]>
GlassFish安裝指南http://www.tkk7.com/askcuix/archive/2009/10/27/299921.htmlChris.CuiChris.CuiTue, 27 Oct 2009 07:18:00 GMThttp://www.tkk7.com/askcuix/archive/2009/10/27/299921.htmlhttp://www.tkk7.com/askcuix/comments/299921.htmlhttp://www.tkk7.com/askcuix/archive/2009/10/27/299921.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/299921.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/299921.html閱讀全文

Chris.Cui 2009-10-27 15:18 發(fā)表評論
]]>
Spring延遲加載EJB代理http://www.tkk7.com/askcuix/archive/2009/09/07/294205.htmlChris.CuiChris.CuiMon, 07 Sep 2009 10:02:00 GMThttp://www.tkk7.com/askcuix/archive/2009/09/07/294205.htmlhttp://www.tkk7.com/askcuix/comments/294205.htmlhttp://www.tkk7.com/askcuix/archive/2009/09/07/294205.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/294205.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/294205.html閱讀全文

Chris.Cui 2009-09-07 18:02 發(fā)表評論
]]>
JMS - 異步消息的使者http://www.tkk7.com/askcuix/archive/2009/08/06/290012.htmlChris.CuiChris.CuiWed, 05 Aug 2009 16:35:00 GMThttp://www.tkk7.com/askcuix/archive/2009/08/06/290012.htmlhttp://www.tkk7.com/askcuix/comments/290012.htmlhttp://www.tkk7.com/askcuix/archive/2009/08/06/290012.html#Feedback1http://www.tkk7.com/askcuix/comments/commentRss/290012.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/290012.html閱讀全文

Chris.Cui 2009-08-06 00:35 發(fā)表評論
]]>
Standalone Client Lookup JNDI from the GlassFishhttp://www.tkk7.com/askcuix/archive/2009/07/30/288985.htmlChris.CuiChris.CuiWed, 29 Jul 2009 16:27:00 GMThttp://www.tkk7.com/askcuix/archive/2009/07/30/288985.htmlhttp://www.tkk7.com/askcuix/comments/288985.htmlhttp://www.tkk7.com/askcuix/archive/2009/07/30/288985.html#Feedback2http://www.tkk7.com/askcuix/comments/commentRss/288985.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/288985.html閱讀全文

Chris.Cui 2009-07-30 00:27 發(fā)表評論
]]>
Weblogic中獲取Server信息http://www.tkk7.com/askcuix/archive/2009/06/23/283707.htmlChris.CuiChris.CuiTue, 23 Jun 2009 03:12:00 GMThttp://www.tkk7.com/askcuix/archive/2009/06/23/283707.htmlhttp://www.tkk7.com/askcuix/comments/283707.htmlhttp://www.tkk7.com/askcuix/archive/2009/06/23/283707.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/283707.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/283707.html閱讀全文

Chris.Cui 2009-06-23 11:12 發(fā)表評論
]]>
SLF4J+logBack, 日志領(lǐng)域中的新秀http://www.tkk7.com/askcuix/archive/2009/03/14/259697.htmlChris.CuiChris.CuiSat, 14 Mar 2009 04:13:00 GMThttp://www.tkk7.com/askcuix/archive/2009/03/14/259697.htmlhttp://www.tkk7.com/askcuix/comments/259697.htmlhttp://www.tkk7.com/askcuix/archive/2009/03/14/259697.html#Feedback5http://www.tkk7.com/askcuix/comments/commentRss/259697.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/259697.html閱讀全文

Chris.Cui 2009-03-14 12:13 發(fā)表評論
]]>
Checkstyle的配置詳解http://www.tkk7.com/askcuix/archive/2009/02/08/253775.htmlChris.CuiChris.CuiSun, 08 Feb 2009 04:47:00 GMThttp://www.tkk7.com/askcuix/archive/2009/02/08/253775.htmlhttp://www.tkk7.com/askcuix/comments/253775.htmlhttp://www.tkk7.com/askcuix/archive/2009/02/08/253775.html#Feedback3http://www.tkk7.com/askcuix/comments/commentRss/253775.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/253775.html Checkstyle可以讓我們養(yǎng)成書寫良好代碼風(fēng)格的習(xí)慣,代碼的整潔也減少了很多bad smell的產(chǎn)生。使用checkstyle的過程中可能需要經(jīng)常的調(diào)整配置文件,有些check過于嚴格,可以根據(jù)實際情況取消一些代碼檢查。  閱讀全文

Chris.Cui 2009-02-08 12:47 發(fā)表評論
]]>
利用JPDA進行Remote Debughttp://www.tkk7.com/askcuix/archive/2008/11/09/239529.htmlChris.CuiChris.CuiSun, 09 Nov 2008 09:10:00 GMThttp://www.tkk7.com/askcuix/archive/2008/11/09/239529.htmlhttp://www.tkk7.com/askcuix/comments/239529.htmlhttp://www.tkk7.com/askcuix/archive/2008/11/09/239529.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/239529.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/239529.html閱讀全文

Chris.Cui 2008-11-09 17:10 發(fā)表評論
]]>
HttpClient之上傳文件http://www.tkk7.com/askcuix/archive/2008/06/21/209731.htmlChris.CuiChris.CuiSat, 21 Jun 2008 14:43:00 GMThttp://www.tkk7.com/askcuix/archive/2008/06/21/209731.htmlhttp://www.tkk7.com/askcuix/comments/209731.htmlhttp://www.tkk7.com/askcuix/archive/2008/06/21/209731.html#Feedback3http://www.tkk7.com/askcuix/comments/commentRss/209731.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/209731.html
 1   File f1 = new File("D:\\download\\aa.txt");
 2   PostMethod filePost = new PostMethod("http://10.3.3.106:8090/~jid=aWHLXB6y4O9a/webdrive/upload.do?contentID=99999820&action=submit");
 3   try{
 4       Part[] parts = {new FilePart("file0", f1)};
 5       filePost.setRequestEntity(new MultipartRequestEntity(parts, filePost.getParams()));
 6   }catch(FileNotFoundException e){
 7       System.out.println("===================file not found exception: " + e);
 8   }
 9   HttpClient client = new HttpClient();
10   // 若上傳的文件比較大 , 可在此設(shè)置最大的連接超時時間 
11   //client.getHttpConnectionManager(). getParams().setConnectionTimeout(5000); 
12   int status = 0;
13   try {
14       
15        status = client.executeMethod(filePost);
16                
17   } catch (HttpException e) {
18        System.out.println("===================http exception: " + e);
19   } catch (IOException e) {
20        System.out.println("===================io exception: " + e);
21   }finally {
22        filePost.releaseConnection();
23   }
24   if (status == HttpStatus.SC_OK) {
25       System.out.println("============================UpLoad file OK! ");
26   } 

     本來URL中的contentID和action兩個參數(shù)我是通過StringPart來傳遞的,結(jié)果傳遞上去的值就成了:
     action=
Content-Transfer-Encoding: 8bit
     submit
     而且目前這種方法上傳的文件,也會在文件內(nèi)容的第一行中出現(xiàn):Content-Transfer-Encoding: 8bit,由于不影響測試的效果,所以就擱置了,等有空時再來研究這個問題,如果有朋友知道問題的原因,也請一定不要吝嗇您的回答哦。

Chris.Cui 2008-06-21 22:43 發(fā)表評論
]]>
HttpClient的一些技巧http://www.tkk7.com/askcuix/archive/2008/06/20/209549.htmlChris.CuiChris.CuiFri, 20 Jun 2008 13:37:00 GMThttp://www.tkk7.com/askcuix/archive/2008/06/20/209549.htmlhttp://www.tkk7.com/askcuix/comments/209549.htmlhttp://www.tkk7.com/askcuix/archive/2008/06/20/209549.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/209549.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/209549.html
一、字符編碼
    某目標頁的編碼可能出現(xiàn)在兩個地方,第一個地方是服務(wù)器返回的 http 頭中,另外一個地方是得到的 html/xml 頁面中。
    1、在 http 頭的 Content-Type 字段可能會包含字符編碼信息。
      例如可能返回的頭會包含這樣子的信息:Content-Type: text/html; charset=UTF-8。這個頭信息表明該頁的編碼是UTF-8,但是服務(wù)器返回的頭信息未必與內(nèi)容能匹配上。比如對于一些雙字節(jié)語言國家,可能服務(wù)器返回的編碼類型是UTF-8,但真正的內(nèi)容卻不是UTF-8編碼的,因此需要在另外的地方去得到頁面的編碼信息;但是如果服務(wù)器返回的編碼不是UTF-8,而是具體的一些編碼,比如gb2312等,那服務(wù)器返回的可能是正確的編碼信息。通過method對象的getResponseCharSet()方法就可以得到http頭中的編碼信息。
    2、對于象xml或者html這樣的文件,允許在頁面中直接指定編碼類型。比如在html中會有<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>這樣的標簽;或者在xml中會有<?xml version="1.0" encoding="gb2312"?>這樣的標簽,在這些情況下,可能與http頭中返回的編碼信息沖突,需要用戶自己判斷到底那種編碼類型應(yīng)該是真正的編碼。

二、自動轉(zhuǎn)向
    根據(jù)RFC中對自動轉(zhuǎn)向的定義,主要有兩種:301和302。301表示永久的移走(Moved Permanently),當返回的是301,則表示請求的資源已經(jīng)被移到一個固定的新地方,任何向該地址發(fā)起請求都會被轉(zhuǎn)到新的地址上。302表示暫時的轉(zhuǎn)向,比如在服務(wù)器端的servlet程序調(diào)用了sendRedirect方法,則在客戶端就會得到一個302的代碼,這時服務(wù)器返回的頭信息中l(wèi)ocation的值就是sendRedirect轉(zhuǎn)向的目標地址。
HttpClient支持自動轉(zhuǎn)向處理,但是象POST和PUT方式這種要求接受后繼服務(wù)的請求方式,暫時不支持自動轉(zhuǎn)向,因此如果碰到POST方式提交后返回的是301或者302的話需要自己處理。需要注意的是,有時候location返回的可能是相對路徑,因此需要對location返回的值做一些處理才可以發(fā)起向新地址的請求。
    另外除了在頭中包含的信息可能使頁面發(fā)生重定向外,在頁面中也有可能會發(fā)生頁面的重定向。引起頁面自動轉(zhuǎn)發(fā)的標簽是:<meta http-equiv="refresh" content="5; url=http://www.ibm.com/">。如果你想在程序中也處理這種情況的話得自己分析頁面來實現(xiàn)轉(zhuǎn)向。需要注意的是,在上面那個標簽中url的值也可以是一個相對地址,如果是這樣的話,需要對它做一些處理后才可以轉(zhuǎn)發(fā)。

三、代理服務(wù)器
    HttpClient中使用代理服務(wù)器非常簡單,調(diào)用HttpClient中setProxy方法就可以,方法的第一個參數(shù)是代理服務(wù)器地址,第二個參數(shù)是端口號。另外HttpClient也支持SOCKS代理。

    httpClient.getHostConfiguration().setProxy(hostName,port);

    HttpClient對http協(xié)議的支持非常好,使用起來很簡單,功能也很強大,具有足夠的靈活性和擴展性。對于想在Java應(yīng)用中直接訪問http資源的編程人員來說,HttpClient是一個不可多得的好工具。

Chris.Cui 2008-06-20 21:37 發(fā)表評論
]]>
HttpClient基本功能的使用http://www.tkk7.com/askcuix/archive/2008/06/20/209547.htmlChris.CuiChris.CuiFri, 20 Jun 2008 13:26:00 GMThttp://www.tkk7.com/askcuix/archive/2008/06/20/209547.htmlhttp://www.tkk7.com/askcuix/comments/209547.htmlhttp://www.tkk7.com/askcuix/archive/2008/06/20/209547.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/209547.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/209547.html     使用 HttpClient 需要以下 6 個步驟:
    1. 創(chuàng)建 HttpClient 的實例
    2. 創(chuàng)建某種連接方法的實例,在這里是 GetMethod。在 GetMethod 的構(gòu)造函數(shù)中傳入待連接的地址
    3. 調(diào)用第一步中創(chuàng)建好的實例的 execute 方法來執(zhí)行第二步中創(chuàng)建好的 method 實例
    4. 讀 response
    5. 釋放連接。無論執(zhí)行方法是否成功,都必須釋放連接
    6. 對得到后的內(nèi)容進行處理

    根據(jù)以上步驟,我們來編寫用GET方法取得某網(wǎng)頁內(nèi)容的代碼。
    1、大部分情況下 HttpClient 默認的構(gòu)造函數(shù)已經(jīng)足夠使用。
 
       HttpClient httpClient = new HttpClient();

    2、創(chuàng)建GET方法的實例。
      在GET方法的構(gòu)造函數(shù)中傳入待連接的地址即可。用GetMethod將會自動處理轉(zhuǎn)發(fā)過程,如果想要把自動處理轉(zhuǎn)發(fā)過程去掉的話,可以調(diào)用方法setFollowRedirects(false)。
     
      GetMethod getMethod = new GetMethod("http://www.ibm.com/");

    3、調(diào)用 httpClient 的 executeMethod 方法來執(zhí)行 getMethod。
      由于是執(zhí)行在網(wǎng)絡(luò)上的程序,在運行executeMethod方法的時候,需要處理兩個異常,分別是HttpException和IOException。引起第一種異常的原因主要可能是在構(gòu)造getMethod的時候傳入的協(xié)議不對,比如將"http"寫成了"htp",或者服務(wù)器端返回的內(nèi)容不正常等,并且該異常發(fā)生是不可恢復(fù)的;第二種異常一般是由于網(wǎng)絡(luò)原因引起的異常,對于這種異常(IOException),HttpClient會根據(jù)你指定的恢復(fù)策略自動試著重新執(zhí)行executeMethod方法。HttpClient的恢復(fù) 策略可以自定義(通過實現(xiàn)接口HttpMethodRetryHandler來實現(xiàn))。通過httpClient的方法setParameter設(shè)置你實現(xiàn)的恢復(fù)策略,本例中使用的是系統(tǒng)提供的默認恢復(fù)策略,該策略在碰到第二類異常的時候?qū)⒆詣又卦?次。executeMethod返回值是一個整數(shù),表示了執(zhí)行該方法后服務(wù)器返回的狀態(tài)碼,該狀態(tài)碼能表示出該方法執(zhí)行是否成功、需要認證或者頁面發(fā)生了跳轉(zhuǎn)(默認狀態(tài)下GetMethod的實例是自動處理跳轉(zhuǎn)的)等。

     //設(shè)置成了默認的恢復(fù)策略,在發(fā)生異常時候?qū)⒆詣又卦?次,在這里你也可以設(shè)置成自定義的恢復(fù)策略
     getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
                                              
new DefaultHttpMethodRetryHandler());
     //執(zhí)行g(shù)etMethod
     int statusCode = client.executeMethod(getMethod);
     if (statusCode != HttpStatus.SC_OK) {
          System.err.println(
"Method failed: " + getMethod.getStatusLine());
     }

    4、在返回的狀態(tài)碼正確后,即可取得內(nèi)容。
      取得目標地址的內(nèi)容有三種方法:
      Ⅰ、getResponseBody,該方法返回的是目標的二進制的byte流;
      Ⅱ、getResponseBodyAsString,這個方法返回的是String類型,值得注意的是該方法返回的String的編碼是根據(jù)系統(tǒng)默認的編碼方式,所以返回的String值可能編碼類型有誤;
      Ⅲ、getResponseBodyAsStream,這個方法對于目標地址中有大量數(shù)據(jù)需要傳輸是最佳的。
      在這里我們使用了最簡單的 getResponseBody方法。

       byte[] responseBody = method.getResponseBody();

    5、釋放連接。
       無論執(zhí)行方法是否成功,都必須釋放連接。
     
       method.releaseConnection();

    6、處理內(nèi)容。
      在這一步中根據(jù)你的需要處理內(nèi)容,本例中只是簡單的將內(nèi)容打印到控制臺。
     
       System.out.println(new String(responseBody));

    下面是程序的完整代碼:
 1   package test;
 2   import java.io.IOException;
 3   import org.apache.commons.httpclient.*;
 4   import org.apache.commons.httpclient.methods.GetMethod;
 5   import org.apache.commons.httpclient.params.HttpMethodParams;
 6   public class GetSample{
 7      public static void main(String[] args) {
 8         //構(gòu)造HttpClient的實例
 9         HttpClient httpClient = new HttpClient();
10         //創(chuàng)建GET方法的實例
11         GetMethod getMethod = new GetMethod("http://www.ibm.com");
12         //使用系統(tǒng)提供的默認的恢復(fù)策略
13         getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
14                                                  new DefaultHttpMethodRetryHandler());
15         try {
16           //執(zhí)行g(shù)etMethod
17           int statusCode = httpClient.executeMethod(getMethod);
18           if (statusCode != HttpStatus.SC_OK) {
19               System.err.println("Method failed: "
20                                         + getMethod.getStatusLine());
21           }
22            //讀取內(nèi)容
23            byte[] responseBody = getMethod.getResponseBody();
24            //處理內(nèi)容
25            System.out.println(new String(responseBody));
26         } catch (HttpException e) {
27            //發(fā)生致命的異常,可能是協(xié)議不對或者返回的內(nèi)容有問題
28            System.out.println("Please check your provided http address!");
29            e.printStackTrace();
30         } catch (IOException e) {
31            //發(fā)生網(wǎng)絡(luò)異常
32            e.printStackTrace();
33         } finally {
34            //釋放連接
35            getMethod.releaseConnection();
36         }
37       }
38    }

二、POST方法
    POST 方法用來向目的服務(wù)器發(fā)出請求,要求它接受被附在請求后的實體,并把它當作請求隊列(Request-Line)中請求URI所指定資源的附加新子項。
    調(diào)用 HttpClient 中的 PostMethod 與 GetMethod 類似,除了設(shè)置 PostMethod 的實例與 GetMethod 有些不同之外,剩下的步驟都差不多。在下面的例子中,省去了與GetMethod相同的步驟,只說明與上面不同的地方。
    構(gòu)造 PostMethod 之前的步驟都相同,與 GetMethod 一樣,構(gòu)造 PostMethod 也需要一個URI參數(shù),在創(chuàng)建了PostMethod的實例之后,需要給method實例填充表單的值,一般的登錄表單中需要有兩個域,第一個是用戶名,第二個是密碼。表單中的域用類 NameValuePair 來表示,該類的構(gòu)造函數(shù)第一個參數(shù)是表單域名名稱,第二參數(shù)是該域的值;將表單所有的值設(shè)置到 PostMethod 中用方法 setRequestBody。如果登錄成功后會轉(zhuǎn)向另外一個頁面,HttpClient對于要求接受后繼服務(wù)的請求,比如POST和PUT,不支持自動轉(zhuǎn)發(fā),因此需要自己對頁面轉(zhuǎn)向做處理。
    代碼如下:
 1  String url = "http://www.test.com/login.jsp";
 2  PostMethod postMethod = new PostMethod(url);
 3  // 填入各個表單域的值
 4  NameValuePair[] data = { new NameValuePair("id""youUserName"),                
 5                           new NameValuePair("passwd""yourPwd") };
 6  // 將表單的值放入postMethod中
 7  postMethod.setRequestBody(data);
 8  // 執(zhí)行postMethod
 9  int statusCode = httpClient.executeMethod(postMethod);
10  // HttpClient對于要求接受后繼服務(wù)的請求,象POST和PUT等不能自動處理轉(zhuǎn)發(fā)
11  // 301或者302
12  if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY ||
13                       statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {
14      // 從頭中取出轉(zhuǎn)向的地址
15      Header locationHeader = postMethod.getResponseHeader("location");
16      String location = null;
17      if (locationHeader != null) {
18         location = locationHeader.getValue();
19         System.out.println("The page was redirected to:" + location);
20      } else {
21         System.err.println("Location field value is null.");
22      }
23      return;
24  }




Chris.Cui 2008-06-20 21:26 發(fā)表評論
]]>
HttpClient簡介http://www.tkk7.com/askcuix/archive/2008/06/20/209538.htmlChris.CuiChris.CuiFri, 20 Jun 2008 12:52:00 GMThttp://www.tkk7.com/askcuix/archive/2008/06/20/209538.htmlhttp://www.tkk7.com/askcuix/comments/209538.htmlhttp://www.tkk7.com/askcuix/archive/2008/06/20/209538.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/209538.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/209538.html     HttpClient 是 Apache Jakarta Common 下的子項目,用來提供高效的、最新的、功能豐富的支持 HTTP 協(xié)議的客戶端編程工具包,該項目就是專門設(shè)計來簡化 HTTP 客戶端與服務(wù)器進行各種通訊編程,通過它,可以讓原來很頭疼的事情現(xiàn)在輕松的解決。

    HttpClient 功能介紹:
    以下列出的是 HttpClient 提供的主要的功能,
  • 實現(xiàn)了所有 HTTP 的方法(GET,POST,PUT,HEAD 等)
  • 支持自動轉(zhuǎn)向
  • 支持 HTTPS 協(xié)議
  • 支持代理服務(wù)器等



Chris.Cui 2008-06-20 20:52 發(fā)表評論
]]>
memcached安裝http://www.tkk7.com/askcuix/archive/2008/05/20/208304.htmlChris.CuiChris.CuiTue, 20 May 2008 08:40:00 GMThttp://www.tkk7.com/askcuix/archive/2008/05/20/208304.htmlhttp://www.tkk7.com/askcuix/comments/208304.htmlhttp://www.tkk7.com/askcuix/archive/2008/05/20/208304.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/208304.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/208304.html1、下載, memcached需要先安裝libevent
   memcached的下載地址:http://danga.com/memcached/download.bml
   libevent的下載地址 :http://www.monkey.org/~provos/libevent/

2、安裝libevent

# tar xvf libevent-1.4.4-stable.tar.gz     
#
 cd libevent-1.4.4-stable    
#
 ./configure --prefix= /opt/cuix/3rdParty/libevent-1.4.4    
#
 make    
#
 make install

   檢查是否安裝成功:

#cd /opt/cuix/3rdParty/libevent-1.4.4/lib

   如果有:
   libevent-1.4.so.2 
   libevent-1.4.so.2.0.0 
   libevent.a 
   libevent.la 
   libevent.so
   這幾個文件存在,說明安裝成功。

3、安裝memcached
   

# tar xvf memcached-1.2.5.tar.gz     
#
 cd memcached-1.2.5   
#
 ./configure --with-libevent=/opt/cuix/3rdParty/libevent-1.4.4 
         --prefix=/opt/cuix/3rdParty/memcached-1.2.5    
# make    
#
 make install

   
   檢查是否安裝成功:

# cd 3rdParty/memcached-1.2.5/bin

   如果memcached 和memcached-debug這2個文件存在,說明安裝成功

4、執(zhí)行

# cd /opt/cuix/3rdParty/memcached-1.2.5/bin    
#
 ./memcached -h

 
   如果出現(xiàn):
  

memcached 1.2.5
   -p <num>      TCP port number to listen on (default: 
11211)
   -U <num>      UDP port number to listen on (default: 
0, off)
   -s <file>     unix socket path to listen on (disables network support)
   -a <mask>     access mask for unix socket
, in octal (default 0700)
   -l <ip_addr>  interface to listen on
, default is INDRR_ANY
   -d            run as a daemon
   -r            maximize core file limit
   -u <username> assume identity of <username> (only when run as root)
   -m <num>      max memory to use for items in megabytes
, default is 64 MB
   -M            return error on memory exhausted (rather than removing items)
   -c <num>      max simultaneous connections
, default is 1024
   -k            lock down all paged memory.  Note that there is a
                 limit on how much memory you may lock.  Trying to
                 allocate more than that would fail
, so be sure you
                 set the limit correctly for the user you started
                 the daemon with (not for -u <username> user
;
                 under sh this is done with 'ulimit -S -l NUM_KB').
   -v            verbose (print errors/warnings while in event loop)
   -vv           very verbose (also print client commands/reponses)
   -h            print this help and exit
   -i            print memcached and libevent license
   -b            run a managed instanced (mnemonic: buckets)
   -P <file>     save PID in <file>
, only used with -d option
   -f <factor>   chunk size growth factor
, default 1.25
   -n <bytes>    minimum space allocated for key+value+flags
, default 48 

    說明安裝成功,并且路徑配置正確。
   有可能會出現(xiàn):

memcached: error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

   說明沒有找到文件:libevent-1.4.so.2

   解決辦法:
   將libevent-1.4.so.2拷貝到任何一個列出的lib下或者軟鏈接就可以了。
   或者 修改.profile文件。加入:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/opt/cuix/3rdParty/libevent-1.4.4/lib 

  
   啟動服務(wù):

./memcached --10 -u cuix -10.3.2.36 -18887 -256 -/tmp/memcached.pid

   
   參數(shù)說明:
    -d選項是啟動一個守護進程
    -m是分配給Memcache使用的內(nèi)存數(shù)量,單位是MB,我這里是10MB
    -u是運行Memcache的用戶,我這里是root
    -l是監(jiān)聽的服務(wù)器IP地址
    -p是設(shè)置Memcache監(jiān)聽的端口,最好是1024以上的端口
    -c選項是最大運行的并發(fā)連接數(shù),默認是1024,按照你服務(wù)器的負載量來設(shè)定
    -P是設(shè)置保存Memcache的pid文件

    停止服務(wù):
    用# ps -e 查看進程,# kill pid memcached的進程號。



Chris.Cui 2008-05-20 16:40 發(fā)表評論
]]>
memcached概述http://www.tkk7.com/askcuix/archive/2008/05/18/208301.htmlChris.CuiChris.CuiSun, 18 May 2008 10:15:00 GMThttp://www.tkk7.com/askcuix/archive/2008/05/18/208301.htmlhttp://www.tkk7.com/askcuix/comments/208301.htmlhttp://www.tkk7.com/askcuix/archive/2008/05/18/208301.html#Feedback0http://www.tkk7.com/askcuix/comments/commentRss/208301.htmlhttp://www.tkk7.com/askcuix/services/trackbacks/208301.html
      首先啟動一個memcached監(jiān)護進程,監(jiān)護進程不需要配置文件,只要在命令行里面加三四個參數(shù)就可以了:
        # ./memcached -d -m 2048 -l 10.0.0.40 -p 11211
      這里指定使用2GB內(nèi)存,監(jiān)聽10.0.0.40的11211端口來啟動memcached。因為32位處理器最多只能有4GB的地址空間。如果你確實需要32位的服務(wù)器處理4-64GB的內(nèi)存(使用PAE),則每個使用2-3GB內(nèi)存。
   
      數(shù)據(jù)庫為了在關(guān)系數(shù)據(jù)庫管理系統(tǒng)上實現(xiàn)ACID,使用了鎖,導(dǎo)致很多讀寫阻塞。而memcached從不會阻塞。首先使用緩存的很多用戶都是用于WEB。這意味著要分配時間出來做多請求處理給不同的系統(tǒng),如mod_perl、PHP等等,這是對全局緩存的一種浪費。如果你使用多線程語言和共享內(nèi)存API,如IPC::Shareable,你的每個線程都擁有獨立的緩存。這個也是共享內(nèi)存的局限性。
   
      memcached服務(wù)器和客戶端實現(xiàn)了全局緩存。實際上,很推薦你在同一臺機器上同時運行WEB結(jié)點和memcached結(jié)點。這會節(jié)省一點網(wǎng)絡(luò)開銷,非常快,它使用 libevent 來處理任意數(shù)量的連接。在Linux上,盡可能使用 epoll 來實現(xiàn)。使用非阻塞的網(wǎng)絡(luò)IO和計算,所以對象在不同的客戶端上可能有不同的狀態(tài)。還使用內(nèi)置的內(nèi)存塊分配和哈希表算法,確保虛擬內(nèi)存不會過來搗亂。
   
    你可能感興趣用戶是否會獲取一個過期的值。服務(wù)器API只有一種獲取數(shù)據(jù)的方法,并有3種提交數(shù)據(jù)的方法:
     * set 無條件的設(shè)置指定的鍵為給定的值。
     * add 添加到緩存,如果不存在。
     * replace 當存在已有值時,替換一下。
    另外,這3個函數(shù)都可以設(shè)置過期時間。

Chris.Cui 2008-05-18 18:15 發(fā)表評論
]]>
主站蜘蛛池模板: 99久久久国产精品免费蜜臀| 亚洲一区影音先锋色资源| 一本岛高清v不卡免费一三区| 一区免费在线观看| 亚洲免费网站观看视频| 亚洲美女一区二区三区| 亚洲精品国产美女久久久| 亚洲?V无码成人精品区日韩| 在线播放免费播放av片| 69成人免费视频| 亚洲视频免费在线播放| 国产免费一区二区三区不卡| v片免费在线观看| 羞羞的视频在线免费观看| 亚洲精品亚洲人成在线| 亚洲一区二区三区四区视频| 久久水蜜桃亚洲av无码精品麻豆| 亚洲精品制服丝袜四区| 国产亚洲精品激情都市| 亚洲国产一区二区视频网站| 免费午夜爽爽爽WWW视频十八禁| 美女黄网站人色视频免费国产 | 成年女人喷潮毛片免费播放| 亚洲免费中文字幕| 最近免费中文字幕高清大全 | 中文字幕不卡亚洲 | 男男gvh肉在线观看免费| 亚洲日本VA午夜在线影院| 男人天堂2018亚洲男人天堂| 亚洲人成小说网站色| 国产亚洲精aa在线看| 亚洲夂夂婷婷色拍WW47| 亚洲色偷偷偷综合网| 老牛精品亚洲成av人片| 免费亚洲视频在线观看| 免费一级毛片在线播放放视频 | 亚洲午夜AV无码专区在线播放| 亚洲精品天堂成人片?V在线播放| 啊灬啊灬别停啊灬用力啊免费看| 免费a级毛片无码a∨性按摩| 国产成人高清亚洲|