锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品自在拍在线播放,18禁亚洲深夜福利人口,中文字幕专区在线亚洲http://m.tkk7.com/dedian/category/14228.html-- 鍏蟲敞鎼滅儲寮曟搸鐨勫紑鍙?/description>zh-cnTue, 27 Feb 2007 08:50:37 GMTTue, 27 Feb 2007 08:50:37 GMT60Again, Problem or Bug for URLConnection ?http://m.tkk7.com/dedian/archive/2006/10/21/76488.htmlDedianDedianFri, 20 Oct 2006 23:20:00 GMThttp://m.tkk7.com/dedian/archive/2006/10/21/76488.htmlhttp://m.tkk7.com/dedian/comments/76488.htmlhttp://m.tkk7.com/dedian/archive/2006/10/21/76488.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/76488.htmlhttp://m.tkk7.com/dedian/services/trackbacks/76488.html
the functions openConnection() and connect() are ok, curious about that problem.

anybody has the same problem or similar problem with URLConnection?


Dedian 2006-10-21 07:20 鍙戣〃璇勮
]]>
Ajax 嫻呰皥http://m.tkk7.com/dedian/archive/2006/10/07/73599.htmlDedianDedianFri, 06 Oct 2006 23:05:00 GMThttp://m.tkk7.com/dedian/archive/2006/10/07/73599.htmlhttp://m.tkk7.com/dedian/comments/73599.htmlhttp://m.tkk7.com/dedian/archive/2006/10/07/73599.html#Feedback2http://m.tkk7.com/dedian/comments/commentRss/73599.htmlhttp://m.tkk7.com/dedian/services/trackbacks/73599.html---紲濆ぇ瀹朵腑縐嬫剦蹇?--

Ajax (AsynchronousJavaScript and XML)鏄繎騫存潵嫻佽鐨勪竴闂╳eb 鎶鏈傚湪Blogjava涓婄湅鍒版湁浜哄紑濮嬪湪浠嬬粛AJAX錛屼絾浠夸經嫻佷簬姒傚康鎴栫悊璁虹殑涓滆タ錛屽浜庢兂鐢ˋjax鐨勫垵瀛﹁呬技涔庝笉鏄緢make sense銆傛垜鎯籌紝瀛︿範浠諱綍涓鏍鋒柊鐨勬妧鏈紝渚嬪瓙鍜屾楠ゆ槸鏋佷負make sense鐨勪袱鏍蜂笢瑗褲?br />
絎旇呮兂緇撳悎榪囧幓鐨勫涔犵粡楠岀畝鍗曡璁蹭嬌鐢ˋjax鐨勫熀鏈楠ゅ拰涓懼嚑涓疄鐢ㄤ緥瀛愩傜敱浜庣瑪鑰呬富瑕佸湪浜庡悗鍙扮鐨勫紑鍙戯紝鎵浠ュ緢澶氳剼鏈茍涓嶆槸寰堟搮闀褲侫jax涔熶富瑕侀檺浜庝互鍓嶅ぇ瀛︾殑淇鍜岃繎鏈熺殑涓浜涗負鍚庡彴绔▼搴忕殑嫻嬭瘯鐨勭畝鍗曞疄鐜般傛墍浠ュ彧鏄竴涓姏鐮栧紩鐜夌殑浣跨敤Ajax鐗堟湰錛屾榪庣浉浜掑涔犱氦嫻併?br />
0. 瀵艱

聽聽聽 1銆備嬌鐢ˋjax鐨勫熀鏈祦紼?br />聽聽聽 2銆備嬌鐢ˋjax鐨勫熀鏈楠ゃ?綆鍗曚緥瀛?-> Demo)
聽聽聽 3銆?/b>鍐嶆潵涓涓緥瀛?Google Suggest)銆?Demo)
聽聽聽 4銆傚搴綔涓?:)


1銆備嬌鐢ˋjax鐨勫熀鏈祦紼?/b>

鍦ㄧ瑪鑰呯湅鏉ワ紝Ajax鏇村儚鏄竴涓畝鍗曠殑緗戠粶妗嗘灦錛屽畠鎻忚堪鐫濡備綍楂樻晥鍦頒嬌緗戠粶鍓嶇鐨勬暟鎹睍鐜板拰緗戠粶鍚庣鐨勬暟鎹箣闂寸殑浜や簰銆傚熀鏈笂錛屽氨鏄祻瑙堝櫒鎻愪緵涓涓猉MLHttpRequest(褰撶劧鍦↖E閲屾槸ActiveXObject)鐨勫璞″悜鍚庡彴绔殑鑴氭湰紼嬪簭鎴栬匰ervlet Classes鍙戦乭ttp璇鋒眰錛屼粠鍚庡彴绔殑鍥炲簲涓幏鍙栨枃鏈暟鎹?濡倄ml鏍煎紡鍜屾渶榪戞湁浜鴻璁虹殑Json鏍煎紡)騫跺祵鍏ュ墠鍙版鐨勭綉欏典腑鎴栬剼鏈腑銆?br />
涓嬪浘鏄竴涓畝鍗曠殑嫻佺▼鍥撅細



2銆備嬌鐢ˋjax鐨勫熀鏈楠ゃ?/b>

涓嬮潰錛屾垜浠粨鍚堜笂闈㈢殑嫻佺▼錛屼互鍙婁竴涓畝鍗曠殑渚嬪瓙(瑙?a >榪欑瘒鏂囩珷)榪囦竴閬嶅熀鏈殑姝ラ銆?钃濊壊浠g爜涓烘爣鍑嗗啓娉?

絎竴姝ワ細Form 浠g爜錛氭帴鍙楀墠鍙扮鐨勮緭鍏ワ紝騫墮氳繃Action鏂規硶(鏂規硶鍑芥暟閲屽寘鍚垱寤篨MLHttpRequest瀵硅薄)鎶妑equest post鍒板悗鍙扮銆?br />
<input id="username" name="username" type="text"
聽 onblur="checkName(this.value,'')" />
<span class="hidden" id="nameCheckFailed">
聽 This name is in use, please try another.
</span>

<script language="javascript">
function checkName(input, response)
{
聽 if (response != ''){
聽聽聽 // Response mode
聽聽聽 message聽聽 = document.getElementById('nameCheckFailed');
聽聽聽 if (response == '1'){
聽聽聽聽聽 message.className = 'error';
聽聽聽 }else{
聽聽聽聽聽 message.className = 'hidden';
聽聽聽 }
聽 }else{
聽聽聽 // Input mode
聽聽聽 url聽 = 'http://localhost/xml/checkUserName.php?q=' + input;
聽聽聽 loadXMLDoc(url);
聽 }
}

var req;

function loadXMLDoc(url)
{
聽聽聽 // branch for native XMLHttpRequest object
聽聽聽 if (window.XMLHttpRequest) {
聽聽聽聽聽聽聽 req = new XMLHttpRequest();
聽聽聽聽聽聽聽 req.onreadystatechange = processReqChange;
聽聽聽聽聽聽聽 req.open("GET", url, true);
聽聽聽聽聽聽聽 req.send(null);
聽聽聽 // branch for IE/Windows ActiveX version
聽聽聽 } else if (window.ActiveXObject) {
聽聽聽聽聽聽聽 req = new ActiveXObject("Microsoft.XMLHTTP");
聽聽聽聽聽聽聽 if (req) {
聽聽聽聽聽聽聽聽聽聽聽 req.onreadystatechange = processReqChange;
聽聽聽聽聽聽聽聽聽聽聽 req.open("GET", url, true);
聽聽聽聽聽聽聽聽聽聽聽 req.send();
聽聽聽聽聽聽聽 }
聽聽聽 }
}
</script>


娉細
1銆?榪欓噷鐨刦orm鍙槸涓涓猧nput box,action鐨勬柟娉曟槸onblur,灝辨槸鍝嶅簲澶卞幓鐒︾偣鐨勪簨浠訛紝鐒跺悗璋冪敤涓涓嚱鏁癱heckName, 榪欎釜鍑芥暟閲岄氳繃XMLHttpRequest鍚慞HP server script 鍙戦丳ost璇鋒眰(鐪嬪緱鍑烘潵錛岃繖閲岀殑php server script鐨勬枃浠跺悕鍙玞heckUserName.php錛屽敮涓鍙傛暟鏄痲)銆?br />2銆傚嚱鏁發oadXMLDoc閲屾湁涓氱敤鐨勫垱寤篨MLHttpRequest瀵硅薄鐨勪唬鐮侊紝鏍囧噯浠g爜鏁寸悊濡備笅錛?br />聽聽聽聽聽聽聽 var req;
聽聽聽 聽聽聽 function foo()
聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 req = false;

聽聽聽 聽聽聽 聽聽聽 // branch for native XMLHttpRequest object
聽聽聽 聽聽聽 聽聽聽 if(window.XMLHttpRequest)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new XMLHttpRequest();
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = false;
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 else if(window.ActiveXObject) // branch for IE/Windows ActiveX version
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new ActiveXObject("Msxml2.XMLHTTP");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new ActiveXObject("Microsoft.XMLHTTP");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = false;
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 if(req)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽 聽聽 聽聽 聽聽 聽聽
//do something here
聽聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽

聽聽聽 聽聽聽 }

絎簩姝ワ細鍝嶅簲鏂囨湰澶勭悊浠g爜錛歑MLHttpRequest瀵硅薄閲屾湁涓被浼兼秷鎭搷搴斿嚱鏁扮殑灞炴э紝鍗抽氳繃璁劇疆 req.onreadystatechange 鏉ュ憡璇塜MLHttpRequest鍦ㄥ摢涓嚱鏁伴噷澶勭悊鏈嶅姟绔繑鍥炵殑鏂囨湰淇℃伅銆?br />濡傚湪涓婇潰鐨勪緥瀛愪腑錛?br />
req.onreadystatechange = processReqChange;
閭d箞鎴戜滑鎺ョ潃瑕佹湁涓涓猵rocessReqChange鐨勫嚱鏁幫細
function processReqChange() 
{
// only if req shows "complete"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200)
{
// ...processing statements go here...
processResponse();
} else {
alert("There was a problem retrieving
the XML data:\n" + req.statusText);
}
}
}


function processResponse()
{
response = req.responseXML.documentElement;
method = response.getElementsByTagName('method')[0].firstChild.data;
result = response.getElementsByTagName('result')[0].firstChild.data;
eval(method + '(\'\', result)');

}
娉細
1銆?鍩烘湰涓?code>processReqChange 鍑芥暟鏄爣鍑嗕唬鐮佺殑鍐欐硶銆?br />2銆傝繖閲岃鐢ㄥ埌鍓嶉潰瀹氫箟鐨勫叏灞鍙橀噺(XMLHttpRequest瀵硅薄)req

絎笁姝ワ細鍚庡彴绔唬鐮?榪欎釜渚嬪瓙鏄痯hp server script)錛氭帴鍙楀墠鍙扮鐨勮姹傦紝澶勭悊鍏跺弬鏁幫紝騫惰繑鍥炵浉搴旂殑緇撴灉銆?br />
鏂囦歡鍚? checkUserName.php

<?php
header('Content-Type: text/xml');

function nameInUse($q)
{聽
聽 if (isset($q)){
聽聽聽 switch(strtolower($q))
聽聽聽 {
聽聽聽聽聽 case聽 'drew' :
聽聽聽聽聽聽聽聽聽 return '1';
聽聽聽聽聽聽聽聽聽 break;
聽聽聽聽聽 case聽 'fred' :
聽聽聽聽聽聽聽聽聽 return '1';
聽聽聽聽聽聽聽聽聽 break;
聽聽聽聽聽 default:
聽聽聽聽聽聽聽聽聽 return '0';
聽聽聽 }
聽 }else{
聽聽聽 return '0';
聽 }

}
?>
<?php echo '<?xml version="1.0" encoding="UTF-8"聽 standalone="yes"?>'; ?>
<response>
聽 <method>checkName</method>
聽 <result><?php
聽聽聽 echo nameInUse($_GET['q']) ?>
聽 </result>
</response>
娉細浠g爜寰堢畝鍗曪紝灝變笉鐢ㄨВ閲婁簡銆傝繖閲岃繑鍥炵殑鏄痻ml鏍煎紡鐨勫瓧絎︿覆銆?br />
鎬諱綋鏁堟灉瑙?a >榪欓噷
杈撳叆"fred"鎴栬?drew"鐨勫悕瀛楋紝澶卞幓鐒︾偣鍚庝細鏄劇ず鍚嶅瓧宸插瓨鍦ㄧ殑淇℃伅銆?br />

3銆傚啀鏉ヤ竴涓緥瀛愩?/b>

榪欓噷鍐嶈涓涓疄鐢ㄧ殑渚嬪瓙錛岃繖鏄互鍓嶄笂璇劇殑涓涓鍫備綔涓氾紝涔熷緢鏈変唬琛ㄦс傛槸鍏充簬Google Suggest(濂藉儚鏂扮殑Google Toolbar涓婂氨鐢ㄧ殑榪欎釜鍔熻兘)鐨勫簲鐢ㄩ棶棰樸傝繖閲屾槸鍐欏ソ鐨?a >DEMO銆傜幇鍦ㄨ秺鏉ヨ秺澶氱殑緗戠珯鎻愪緵綾諱技Web Service鐨凙PI, 鎴戜滑鍒╃敤浠栦滑鎻愪緵鐨凙PI URL鍙互榪斿洖涓浜涙垜浠敤鐨勭潃鐨勬暟鎹紝鏀懼湪鎴戜滑鐨勭綉欏典笂銆傝繖閲屽氨鐢ㄧ殑涓夾jax銆傚彧涓嶈繃鏈変簺榪斿洖鏉ョ殑鏂囨湰鏁版嵁鏄痻ml鏍煎紡鐨勶紝灝卞彲浠ュ埄鐢ㄤ笂闈㈢殑綆鍗曚緥瀛愭潵澶勭悊錛屼絾寰堝鍍廏oogle Suggest閭f牱鏄繑鍥炰竴孌電被浼間唬鐮佹牸寮忕殑鏂囨湰銆傛垜浠氨瑕佸埄鐢↗avascript鐨別val鍑芥暟錛屾妸榪欎簺鏂囨湰褰撲綔涓孌典唬鐮佸湪宓屽叆鑷繁鐨勭綉欏典腑銆傚鏋滃祵鍏ョ殑浠g爜涓惈鏈夊嚱鏁幫紝鍒欓渶瑕佽嚜宸卞啀鍐欎竴涓悓鍚嶇殑鍑芥暟浣滀負瀹炵幇銆?榪欏氨鏄祦紼嬪浘涓殑optional鐨刦unc 3)

榪欓噷瀹屾暣浠g爜灝變笉璐翠簡錛岃創涓浜涘叧閿唬鐮?鍘熸湰鍚庡彴绔槸鐢↗ava Servlet鍐欑殑錛屼絾鍋歞emo鐨勭┖闂存病鏈塗omcat涓嶆敮鎸丼ervlet,鎵浠ユ敼鐢≒hp瀹炵幇錛屽ぇ瀹跺彲浠ヨ嚜宸辯敤Java鍐嶅啓涓杈逛綔涓哄搴綔涓?:) )錛?br />
1) form 浠g爜錛?br />
<form name = "QForm" method="POST" action="google_suggest.php">
聽聽聽 <table bgcolor="8080C0" width="90%" >
聽聽聽 <tr>
聽聽聽 聽聽聽 <td聽 nowrap>Search Term:</td>
聽聽聽 聽聽聽 <td ><input type="text" name="qtext"聽 onkeyup="return GetSuggestion()" size="60"></td>
聽聽聽 </tr>
聽聽聽 <tr>
聽聽聽 聽聽聽 <th colspan="2" align="left" bgcolor="#A8A8FF"><DIV id=google_suggest_target>results go here . . . </DIV></th>
聽聽聽 </tr>
聽聽聽 </table>
聽聽聽 </form>

娉細
a. 鐪嬪緱鍑烘潵錛岃鎶婃煡璇㈢殑瀛楃涓瞤ost鍒癵oogle_suggest.php涓?br />b. action鐨勫嚱鏁版槸GetSuggestion()錛屽叾榪斿洖鐨勫瓧絎︿覆浼氭樉紺哄湪棰勭暀鐨勭綉欏電┖闂撮噷銆?br />
2) 鍚庡彴绔唬鐮?PHP)錛氳繖閲屼富瑕佹帴鏀跺墠鍙扮殑璇鋒眰錛屽茍涓嶈姹傝漿鍖栦負鍚慓oogle Suggest鐨凙PI URL璇鋒眰錛屾妸鎺ユ敹鍒扮殑鏂囨湰淇℃伅榪斿洖緇欏墠绔備唬鐮佸緢綆鍗曪紝濡備笅錛?br />
鏂囦歡鍚嶏細google_suggest.php

<?php
function getGoogleSuggest($q)
{

聽聽聽 $url = "http://www.google.com/complete/search?hl=en&js=true&qu=" . $q;
聽聽聽 return file_get_contents($url);
}
?>

<?php echo getGoogleSuggest($_POST['q']) ?>

娉細
a銆?Google Suggest API 榪斿洖鐨勬槸涓涓唬鐮佹牸寮忕殑鏂囨湰淇℃伅錛屽涓嬶細
sendRPCDone(frameElement, "", new Array(), new Array(), new Array(""));
鎵浠ユ垜浠啀鍓嶅彴鎺ュ彈鍒拌繖涓枃鏈俊鎭箣鍚庯紝搴旇鍐欎竴涓猻endRPCDone鐨勫嚱鏁版潵鍋氳繘涓姝ヤ俊鎭鐞?姣斿璇村垪琛ㄥ嚭鏌ヨ緇撴灉)銆?br />
3) 鍓嶅彴鏂囨湰澶勭悊浠g爜錛?br />
聽聽聽 <script type="text/javascript">
聽聽聽 聽聽聽 var req;
聽聽聽 聽聽聽 function GetSuggestion()
聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 req = false;
聽聽聽 聽聽聽 聽聽聽 var f = document.QForm;

聽聽聽 聽聽聽 聽聽聽 // branch for native XMLHttpRequest object
聽聽聽 聽聽聽 聽聽聽 if(window.XMLHttpRequest)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new XMLHttpRequest();
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = false;
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 else if(window.ActiveXObject) // branch for IE/Windows ActiveX version
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new ActiveXObject("Msxml2.XMLHTTP");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 try
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = new ActiveXObject("Microsoft.XMLHTTP");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 catch(e)
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 req = false;
聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 if(req)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 var url = "google_suggest.php";
聽聽聽聽聽聽聽
聽聽聽 聽聽聽 聽聽聽 聽聽聽 req.onreadystatechange = processReqChange;
聽聽聽 聽聽聽 聽聽聽 聽聽聽 req.open("POST", url, true);

聽聽聽聽聽聽聽 聽聽聽 聽聽聽 req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 req.setRequestHeader("Method", "POST " + url + " HTTP/1.1");
聽聽聽 聽聽聽 聽聽聽 聽聽聽 req.send("q=" + escape(document.QForm.qtext.value));
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽

聽聽聽 聽聽聽 }
聽聽聽 聽聽聽
聽聽聽 聽聽聽 function processReqChange()
聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 if(req.readyState == 4) // only if req shows "loaded"
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 if (req.status == 200) // only if "OK"
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 {
聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽聽 聽聽聽 x = req.responseText;
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 eval(x);
聽聽
聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 else
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 {
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽 聽聽聽 聽聽聽 聽聽聽聽聽 alert("There was a problem retrieving the XML data:\n" + req.statusText);
聽聽聽 聽聽聽 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 else if(req.readyState == 2)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 }
聽聽聽 聽聽聽
聽聽聽 聽聽聽 function sendRPCDone(frameElement, qString, arr1, arr2, arr3)
聽聽聽 聽聽聽 {
聽聽聽 聽聽聽
聽聽聽 聽聽聽 聽聽聽 var suggest_results = eval(arr1);
聽聽聽 聽聽聽 聽聽聽 var counts = eval(arr2);
聽聽聽 聽聽聽 聽聽聽 var htmlstr = "<TABLE cellspacing=4 border=0>";
聽聽聽 聽聽聽 聽聽聽 for (var i=0; i < suggest_results.length; i++)
聽聽聽 聽聽聽 聽聽聽 {
聽聽聽 聽聽聽 聽聽聽 聽聽聽 htmlstr += "<tr><td><a href=\"javascript:self.location=\'http://www.google.com/search?hl=en&q=" + suggest_results[i] + "&btnG=Google+Search\'\">" + suggest_results[i] + "</a></td>";
聽聽聽 聽聽聽 聽聽聽 聽聽聽 htmlstr += "<TD width=200><font color= 228b22>" + counts[i] + "</font></TD></TR>"
聽聽聽 聽聽聽 聽聽聽聽聽聽 聽聽聽 聽
聽聽聽 聽聽聽 聽聽聽 }
聽聽聽 聽聽聽 聽聽聽 htmlstr += "</TABLE>";
聽聽聽 聽聽聽 聽聽聽 document.getElementById("google_suggest_target").innerHTML = htmlstr;
聽聽聽 聽聽聽
聽聽聽 聽聽聽 }
聽聽聽 聽聽聽
聽聽聽 聽聽聽 </script>

4銆傚搴綔涓?:)

涓瀹氳鑷繁鍐欎竴浜涗唬鐮侊紝鎵嶈兘宸╁浐鐭ヨ瘑:)
棰樼洰錛?br />鎴戜滑緇忓父鐢?a >del.icio.us鏉ユ敹钘忔垜浠枩嬈㈢殑緗戠珯鎴栬呮枃绔狅紝騫跺姞涓浜涚被浼艱涔︾瑪璁扮殑娉ㄩ噴銆傞偅涔堟垜浠庝箞鍒╃敤del.icio.us鎻愪緵鐨凙PI鏉ヨ闂垜浠殑璇諱功絎旇淇℃伅錛屽茍鏄劇ず鍦ㄨ嚜宸辯殑Blog閲屽憿錛?br />鎻愮ず錛?br />1銆備綘瑕佹湁涓涓猟el.icio.us鐨勮處鍙鳳紝騫朵笖宸茬粡鏈夋墍緗戦〉鏀惰棌浣滀負瀹為獙鏁版嵁:)
2銆侫PI URL 鏄?"http://del.icio.us/feeds/json/" + "浣犵殑璐﹀彿鍚?錛涜嚜宸卞弬鐪嬩竴涓嬶紝鐪嬭繑鍥炰粈涔堟牱鐨勬牸寮忔枃鏈傚彟澶栵紝濡傛灉瑕侀檺鍒惰繑鍥炵殑璁板綍鏁幫紝鍙互鍔??count=10"榪欐牱鐨勫弬鏁般?br />

鏈鍚庯紝紲濆ぇ瀹朵腑縐嬫剦蹇紒

---------------------------瀹?---------------------------






Dedian 2006-10-07 07:05 鍙戣〃璇勮
]]>
PHP/Java Integration on Windowshttp://m.tkk7.com/dedian/archive/2006/10/06/73506.htmlDedianDedianFri, 06 Oct 2006 01:05:00 GMThttp://m.tkk7.com/dedian/archive/2006/10/06/73506.htmlhttp://m.tkk7.com/dedian/comments/73506.htmlhttp://m.tkk7.com/dedian/archive/2006/10/06/73506.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/73506.htmlhttp://m.tkk7.com/dedian/services/trackbacks/73506.htmlhelp doc: http://php-java-bridge.sourceforge.net/

1- Make sure u have Installed Apache 2 & PHP 5 and Java J2EE 1.5
2- download pecl-5.0.5-Win32.zip and php-java-bridge_2.0.8.zip, which will include
extra dll(s)
聽聽 - unpack pecl pkg to your extensions folder, in PHP5 its ext.
聽聽 - unpack java-Bridge to root php folder, in my case its simply C:\PHP
聽聽
Note:
1. the java-Bridge inculdes new versions of certain files like php_java.dll
聽聽 so, it would be wise to rename your old files that came with PECL pkg for example
聽聽 file_old, to rollback at anytime.
2. Don't run batch file under php-java-bridge after unpacking to php root folder, just add following lines in php.ini configure file (depends on installation fold of j2ee):

extension=php_java.dll
extension_dir = "C:\php\ext"
[java]
java.java_home=C:\Program Files\Java\jre1.5.0_06
java.java=C:\Program Files\Java\jre1.5.0_06\bin\javaw.exe
java.log_level=2
;java.log_file=ext/JavaBridge.log



Dedian 2006-10-06 09:05 鍙戣〃璇勮
]]>
HttpURLConnect Problemhttp://m.tkk7.com/dedian/archive/2006/09/21/70965.htmlDedianDedianWed, 20 Sep 2006 22:32:00 GMThttp://m.tkk7.com/dedian/archive/2006/09/21/70965.htmlhttp://m.tkk7.com/dedian/comments/70965.htmlhttp://m.tkk7.com/dedian/archive/2006/09/21/70965.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/70965.htmlhttp://m.tkk7.com/dedian/services/trackbacks/70965.htmlHttpURLConnection.getResponseCode(), it seems tthat JVM hangs for quite a while. Somebody says that is maybe the problem of http server who must be a Microsoft webserver. Here and here are the bug report information for Java 1.3 or before. Though it is said that the problem has been solved after java 1.4, i still get undesirable a long time waiting before a SocketException (Connection reset) is thrown out. Btw, conn.setConnectTimeout or conn.setConnectTimeout is involved for this problem. I am not sure if there is any method that can save time to skip those bad links.


Dedian 2006-09-21 06:32 鍙戣〃璇勮
]]>
Getting the IP Address and Hostnamehttp://m.tkk7.com/dedian/archive/2006/08/18/64237.htmlDedianDedianThu, 17 Aug 2006 22:53:00 GMThttp://m.tkk7.com/dedian/archive/2006/08/18/64237.htmlhttp://m.tkk7.com/dedian/comments/64237.htmlhttp://m.tkk7.com/dedian/archive/2006/08/18/64237.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/64237.htmlhttp://m.tkk7.com/dedian/services/trackbacks/64237.html1. Getting the IP Address of a Hostname
    try 
{
InetAddress addr = InetAddress.getByName("yahoo.com");
byte[] ipAddr = addr.getAddress();

// Convert to dot representation
String ipAddrStr = "";
for (int i=0; i<ipAddr.length; i++) {
if (i > 0) {
ipAddrStr += ".";
}
ipAddrStr += ipAddr[i]&0xFF;
}
}
catch (UnknownHostException e) {
}


2. Getting the Hostname of an IP Address

This example attempts to retrieve the hostname for an IP address. Note that getHostName() may not succeed, in which case it simply returns the IP address.

try {
// Get hostname by textual representation of IP address
InetAddress addr = InetAddress.getByName("127.0.0.1");

// Get hostname by a byte array containing the IP address
byte[] ipAddr = new byte[]{127, 0, 0, 1};
addr = InetAddress.getByAddress(ipAddr);

// Get the host name
String hostname = addr.getHostName();

// Get canonical host name
String hostnameCanonical = addr.getCanonicalHostName();
} catch (UnknownHostException e) {
}

3. Getting the IP Address and Hostname of the Local Machine

    try {
InetAddress addr = InetAddress.getLocalHost();

// Get IP Address
byte[] ipAddr = addr.getAddress();

// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}



Dedian 2006-08-18 06:53 鍙戣〃璇勮
]]>
CVS Tutorialhttp://m.tkk7.com/dedian/archive/2006/07/20/59103.htmlDedianDedianWed, 19 Jul 2006 23:06:00 GMThttp://m.tkk7.com/dedian/archive/2006/07/20/59103.htmlhttp://m.tkk7.com/dedian/comments/59103.htmlhttp://m.tkk7.com/dedian/archive/2006/07/20/59103.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/59103.htmlhttp://m.tkk7.com/dedian/services/trackbacks/59103.html--聽 Getting Ready to Use CVSFirst set the variable CVSROOT to /class/`username`/cvsroot
[Or any other directory you wish]
[For csh/tcsh: setenv CVSROOT ~/cvsroot]
[For bash/ksh: CVSROOT=~/cvsroot;export CVSROOT]

Next run cvsinit. It will create this directory along with the subdirectory CVSROOT and put several files into CVSROOT.

-- How to put a project under CVS

A simple program consisting of multiple files is in /workspaces/project.

To put this program under cvs first

cd to /workspaces/project

Next

cvs import -m "Sample Program" project sample start

CVS should respond with
N project/Makefile
N project/main.c
N project/bar.c
N project/foo.c

No conflicts created by this import


If your were importing your own program, you could now delete the original source.
(Of course, keeping a backup is always a good idea)

-- Basic CVS Usage

Now that you have added 'project' to your CVS repository, you will want to be able to modify the code.

To do this you want to check out the source. You will want to cd to your home directory before you do this.

cd

cvs checkout project

CVS should respond with
cvs checkout: Updating project
U project/Makefile
U project/bar.c
U project/foo.c
U project/main.c



This creates the project directory in your home directory and puts the files: Makefile, bar.c, foo.c, and main.c into the directory along with a CVS directory which stores some information about the files.

You can now make changes to any of the files in the source tree.
Lets say you add a printf("DONE\n"); after the function call to bar()
[Or just cp /class/bfennema/project_other/main2.c to main.c]

Now you have to check in the new copy

cvs commit -m "Added a DONE message." main.c

CVS should respond with
Checking in main.c;
/class/'username'/cvsroot/project/main.c,v <-- main.c
new revision: 1.2; previous revision: 1.1
done


Note, the -m option lets you define the checking message on the command line. If you omit it you will be placed into an editor where you can type in the checking message.

-- Using CVS with Multiple Developers

To simulate multiple developers, first create a directory for your second developer.
Call it devel2 (Create it in your home directory).
Next check out another copy of project.
  • HINT: cvs checkout project
Next, in the devel2/project directory, add a printf("YOU\n"); after the printf("BAR\n");
[Or copy /class/bfennema/project_other/bar2.c to bar.c]

Next, check in bar.c as developer two.
  • HINT: cvs commit -m "Added a YOU" bar.c
Now, go back to the original developer directory.
[Probably /class/'username'/project]

Now look at bar.c. As you can see, the change made by developer one has no been integrated into your version. For that to happen you must

cvs update bar.c

CVS should respond with
U bar.c

Now look at bar.c. It should now be the same as developer two's.
Next, edit foo.c as the original developer and add printf("YOU\n"); after the printf("FOO\n");
[Or copy /class/bfennema/project_other/foo2.c to foo.c]

Then check in foo.c

  • HINT: cvs commit -m "Added YOU" foo.c
Next, cd back to developer two's directory.
Add printf("TOO\n"); after the printf("FOO\n");
[Or copy /class/bfennema/project_other/foo3.c to foo.c]

Now type

cvs status foo.c

CVS should respond with
===================================================================
File: foo.c             Status: Needs Merge

   Working revision:    1.1.1.1 'Some Date'
   Repository revision: 1.2     /class/'username'/cvsroot/project/foo.c,v
   Sticky Tag:          (none)
   Sticky Date:         (none)
   Sticky Options:      (none)
The various status of a file are:
Up-to-date
    The file is identical with the latest revision in the repository.
Locally Modified
    You have edited the file, and not yet committed your changes.
Needing Patch
    Someone else has committed a newer revision to the repository.
Needs Merge
    Someone else has committed a newer revision to the repository, and you have also made modifications to the file.

Therefore, this is telling use we need to merge our changes with the changes made by developer one. To do this

cvs update foo.c

CVS should respond with
RCS file: /class/'username'/cvsroot/project/foo.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
Merging differences between 1.1.1.1 and 1.2 into foo.c
rcsmerge: warning: conflicts during merge
cvs update: conflicts found in foo.c
C foo.c


Since the changes we made to each version were so close together, we must manually adjust foo.c to look the way we want it to look. Looking at foo.c we see:
void foo()
{
  printf("FOO\n");
<<<<<<< foo.c
  printf("TOO\n");
=======
  printf("YOU\n");
>>>>>>> 1.2
}

We see that the text we added as developer one is between the ======= and the >>>>>>> 1.2.
The text we just added is between the ======= and the <<<<<<< foo.c

To fix this, move the printf("TOO\n");to after the printf("YOU\n");line and delete the additional lines the CVS inserted. [Or copy /class/bfennema/project_other/foo4.c to foo.c]
Next, commit foo.c

cvs commit -m "Added TOO" foo.c

Since you issued a cvs update command and integrated the changes made by developer one, the integrated changes are committed to the source tree.

-- Additional CVS Commands

To add a new file to a module:
  • Get a working copy of the module.
  • Create the new file inside your working copy.
  • use cvs add filename to tell CVS to version control the file.
  • use cvs commit filename to check in the file to the repository.

Removing files from a module:
  • Make sure you haven't made any uncommitted modifications to the file.
  • Remove the file from the working copy of the module. rm filename.
  • use cvs remove filename to tell CVS you want to delete the file.
  • use cvs commit filename to actually perform the removal from the repository.

For more information see the cvs man pages or the cvs.ps file in cvs-1.7/doc.

---------------
copy from http://www.csc.calpoly.edu/~dbutler/tutorials/winter96/cvs/

Dedian 2006-07-20 07:06 鍙戣〃璇勮
]]>
Retrieve values in HashTable or HashMaphttp://m.tkk7.com/dedian/archive/2006/06/02/49836.htmlDedianDedianThu, 01 Jun 2006 23:16:00 GMThttp://m.tkk7.com/dedian/archive/2006/06/02/49836.htmlhttp://m.tkk7.com/dedian/comments/49836.htmlhttp://m.tkk7.com/dedian/archive/2006/06/02/49836.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/49836.htmlhttp://m.tkk7.com/dedian/services/trackbacks/49836.html
Collection c = links.value();
Vector<ComplexDataType> v = new Vector<ComplexDataType>(c);
for(int i = 0; i< v.size(); i++)
{
聽聽聽 ComplexDataType tempData = (ComplexDataType)v.get(i);
聽聽聽 dosomethingwith(tempData);
}


P.S. Map provides three views of map: keySet, entrySet and values collection, we can use any of them .


Dedian 2006-06-02 07:16 鍙戣〃璇勮
]]>
Java Reading & Writing filehttp://m.tkk7.com/dedian/archive/2006/05/31/49154.htmlDedianDedianWed, 31 May 2006 00:12:00 GMThttp://m.tkk7.com/dedian/archive/2006/05/31/49154.htmlhttp://m.tkk7.com/dedian/comments/49154.htmlhttp://m.tkk7.com/dedian/archive/2006/05/31/49154.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/49154.htmlhttp://m.tkk7.com/dedian/services/trackbacks/49154.html 1. Reading text from Standard Input

try 
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = "";
while (str != null)
{
System.out.print("> some prompt ");
str = in.readLine();
dosomethingwith(str);
}
}
catch (IOException e)
{
}

2. Reading text from a file
try 
{
BufferedReader in = new BufferedReader(new FileReader("filename"));
String str;
while ((str = in.readLine()) != null)
{
dosomethingwith(str);
}
in.close();
}
catch (IOException e)
{
}

3. Reading a file into a BityArray

    // Returns the contents of the file in a byte array.
public static byte[] getBytesFromFile(File file) throws IOException
{
InputStream is = new FileInputStream(file);

// Get the size of the file
long length = file.length();

// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE)
{
// File is too large
}

// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0)
{
offset += numRead;
}

// Ensure all the bytes have been read in
if (offset < bytes.length)
{
throw new IOException("Could not completely read file "+file.getName());
}

// Close the input stream and return bytes
is.close();
return bytes;

}

4. Writing to a file

try 
{
BufferedWriter out = new BufferedWriter(new FileWriter("filename"));
out.write("some string");
out.close();
}
catch (IOException e)
{
}
Note: If the file does not already exist, it is automatically created.

5. Appending to a file


try 
{
BufferedWriter out = new BufferedWriter(new FileWriter("filename", true));
out.write("appending String");
out.close();
}
catch (IOException e)
{
}

6. Using a Random Access File

try 
{
File f = new File("filename");
RandomAccessFile raf = new RandomAccessFile(f, "rw");

// Read a character
char ch = raf.readChar();

// Seek to end of file
raf.seek(f.length());

// Append to the end
raf.writeChars("aString");
raf.close();
}
catch (IOException e)
{
}


reference:
http://javaalmanac.com/egs/java.io/pkg.html


Dedian 2006-05-31 08:12 鍙戣〃璇勮
]]>
convertion between InputStream & Stringhttp://m.tkk7.com/dedian/archive/2006/04/29/43911.htmlDedianDedianFri, 28 Apr 2006 21:17:00 GMThttp://m.tkk7.com/dedian/archive/2006/04/29/43911.htmlhttp://m.tkk7.com/dedian/comments/43911.htmlhttp://m.tkk7.com/dedian/archive/2006/04/29/43911.html#Feedback1http://m.tkk7.com/dedian/comments/commentRss/43911.htmlhttp://m.tkk7.com/dedian/services/trackbacks/43911.html
InputStream convertToInputStream(String str)
{
聽聽聽 聽聽聽 ByteArrayInputStream is = new ByteArrayInputStream(str.getBytes());
聽聽聽聽聽聽聽 return is;
}

2. InputStream --> String
聽聽聽聽
String convertToString(InputStream is)
{
聽聽聽 聽聽
聽聽聽聽聽聽 BufferedReader in = new BufferedReader(new InputStreamReader(is));
聽聽聽 聽聽聽 StringBuffer buffer = new StringBuffer();
聽聽聽 聽聽聽 String line = "";
聽聽聽 聽聽聽 while ((line = in.readLine()) != null)
聽聽聽 聽聽聽 {
聽聽聽聽 聽聽聽 聽聽聽 buffer.append(line);
聽聽聽聽 聽聽聽 }
聽聽聽聽 聽聽聽 return buffer.toString();
聽聽聽 聽聽聽 聽聽聽
}

When I do the socket programming, I always need to deal with inputstream and string, above are the basic ways to so that, but I am not sure if there are any simpler ways to do that...



Dedian 2006-04-29 05:17 鍙戣〃璇勮
]]>
Simple way to convert between int & String in Javahttp://m.tkk7.com/dedian/archive/2006/04/25/42930.htmlDedianDedianTue, 25 Apr 2006 01:22:00 GMThttp://m.tkk7.com/dedian/archive/2006/04/25/42930.htmlhttp://m.tkk7.com/dedian/comments/42930.htmlhttp://m.tkk7.com/dedian/archive/2006/04/25/42930.html#Feedback0http://m.tkk7.com/dedian/comments/commentRss/42930.htmlhttp://m.tkk7.com/dedian/services/trackbacks/42930.html
1. int --> String
聽聽聽 a. apply "+" operation with an empty string
聽聽聽 聽聽 聽聽 ex:
聽聽聽 聽聽 聽聽 int index = 20;
聽聽聽 聽聽 聽聽 String indexStr = "" + index;
聽聽聽 b. use String function
聽聽聽 聽聽 聽聽 ex:
聽聽聽 聽聽 聽聽 int index = 20;
聽聽聽 聽聽 聽聽 String indexStr = String.valueOf(index);
聽聽聽 c. convert to Integer class firstly
聽聽聽 聽聽 聽聽 ex:
聽聽聽 聽聽 聽聽 int index = 20;
聽聽聽 聽聽 聽聽 Integer Index = new Integer(index);
聽聽聽 聽聽 聽聽 String indexStr = Index.toString();
聽聽聽 聽聽 聽聽 or
聽聽聽 聽聽 聽聽 String indexStr = Integer.toString(index);

2. String --> int
聽聽聽 a. use class Integer parse funtion
聽聽聽 聽聽 ex:
聽聽聽 聽聽 String indexStr = "20";
聽聽聽 聽聽 int index = Integer.parseInt(indexStr);
聽聽聽 聽聽 or
聽聽聽 聽聽 int index = (new Integer(indexStr)).intValue();

note: above convertion methods can be applied to other number types, such as float, long, double...

P.S. for 1.a method, should be noticed that following two expression are different:
int i = 7;
int j = 8;

String str1 = i + j + ""; //(str1 == "15")
String str2 = "" + i + j; //(str2 == "78")



Dedian 2006-04-25 09:22 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 在线观看免费毛片| 成人午夜视频免费| 国产专区一va亚洲v天堂| 国产综合成人亚洲区| 国产美女无遮挡免费网站| 亚洲国产精品无码第一区二区三区| 无码人妻一区二区三区免费手机| 亚洲国产中文在线二区三区免| 91久久成人免费| 国内精品久久久久影院亚洲| 日韩毛片无码永久免费看| 成人精品国产亚洲欧洲| 亚洲国产婷婷综合在线精品| 国产乱妇高清无乱码免费| 国产∨亚洲V天堂无码久久久| 久久99精品视免费看| 亚洲电影免费观看| 全免费一级午夜毛片| 免费福利资源站在线视频| 亚洲色无码专区在线观看| 91福利免费视频| 色偷偷噜噜噜亚洲男人| 国产亚洲精久久久久久无码77777 国产亚洲精品成人AA片新蒲金 | 特级做A爰片毛片免费看无码| 91亚洲国产成人久久精品网站| 永久免费av无码网站韩国毛片| 亚洲精品无AMM毛片| 亚洲中文字幕无码一区二区三区 | 亚洲AⅤ无码一区二区三区在线| 国产久爱免费精品视频 | 中文字幕在线观看亚洲| 免费被黄网站在观看| 国产中文字幕在线免费观看| 亚洲另类古典武侠| 亚洲一级特黄无码片| 无码人妻精品中文字幕免费东京热| 小说区亚洲自拍另类| 亚洲网站视频在线观看| 亚洲成A人片在线观看中文| 最近2019免费中文字幕视频三| 国产AV无码专区亚洲AV麻豆丫|