urlconnection

search for more blogs here

 

"??Java ?Web????POST??" posted by ~Ray
Posted on 2008-11-13 12:22:13

向Web站点发送GET请求是很容易的。比如,创建一个URL对象http://www sun com/somepage jsp?key=value,而不是http://www sun com/somepage jsp。然而如果你需要发送一个POST请求时又该怎样做呢? 向一个Web站点发送POST请求只需要简单的几步。首先要和URL下的URLConnection对话。URLConnection可以很容易的从URL得到。比如: // Using java net. URL and //java net. URLConnection URL url = new URL("http://jobsearch dice com/jobsearch/jobsearch cgi"); URLConnection connection = url openConnection(); 然后把连接设为输出模式。URLConnection通常作为输入来使用,比如下载一个Web页。通过把URLConnection设为输出,你可以把数据向你个Web页传送。下面是如何做: ... connection setDoOutput(true); 最后,为了得到OutputStream,简单起见,把它约束在Writer并且放入POST信息中,例如: ... OutputStreamWriter out = new OutputStreamWriter(uc getOutputStream(), "8859_1"); out write("username=bob&password="+password+""); // remember to clean up out flush(); out close(); 这样就可以发送一个看起来象这样的POST: POST /jobsearch/jobsearch cgi HTTP 1.0 ACCEPT: text/plain Content-type: application/x-www-form-urlencoded Content-length: 99 username=bob password=someword 一旦发送成功,用以下方法就可以得到服务器的回应: connection getInputStream(); 一些Web站点用POST形式而不是GET,这是因为POST能够携带更多的数据,而且不用URL,这使得它看起来不那么庞大。使用上面列出的大致的代码,Java代码可以和这些站点轻松的实现对话。 连接位所提供的内容、资料、图库、香港排名、香港会员、香港、香港图库、会员、开奖结果、特码、信息、规律、公司、公式、历史、记录、六合彩研究、图片和特码资讯,只应用在合法的特码资料探讨,暂不适用于其它非法的特码资料资讯,外围博彩和非法使用。如引为他用后果自负。本网概不负责。如因本中心所引起的所有民事诉讼均或相关均与本公司无关,图库提供所有特码信息仅供数理研究之用,任何人不得用以赢利!!本站 所服务范围:图库、特码、图、资料,开奖记录、 香港十二生肖.黄大仙论坛救世报射箭图,天线宝宝,.聊天室.惠泽社群,六合采彩.免费图库.开奖时间,马会挂牌,开奖结果、图库,,,票,六合,,香港,香港公司,六合彩,一码中特、单双中特、六合彩免费图库、金多宝之脑筋急转弯、平码三中三,曾道人白小姐天线宝宝等所有资讯只为搜索引擎排名与学习研究之用. 本站所有六合彩资料来自互联网,如果本站侵犯您的权益请联系: 香港彩票资讯网 (宣)!。

Forex Groups - Tips on Trading

Related article:
http://cs1022.spaces.live.com/Blog/cns!34345A50FF5F1AC1!180.entry

comments | Add comment | Report as Spam


"URLConnection???(JavaVM1.4.X????)" posted by ~Ray
Posted on 2008-01-01 21:17:55

JavaVM""Sun˥꡼ƤΤʤΤǿ⤤ΤǤϤʤȻפ줬ǤWeb˸Ƥʤ󤫤ɤȡƳʤǤʤäꤷޤäǤϡƤ뤬б᤯ʤʤȤäƤ⡤ȯܿͤȤäǽʤ櫓Ǥ͡ˡǥݡȤŪäꤷƤΤ(ȡͤΤͤϻפäƤǤɤǤ礦͡)ꡥITΤ鸫ФΤäꤷSunⰭϤʤ¾ϰƳäꤷƤʤäꎥȤäˤͤΤͤϹͤƤޤ ưϡURLConnectionݤˡƱǡǤƤޤΤΤǤԤ̿򤷤ˤϡƱܤʣϿƤޤޤϤ󤫤ͽ̥顼֤뤳ȤǤ礦Ƥ餷ȤϴñǤƤ⡤ޤURLConnectionΤ꤬ʤƺǽˤϻפĤʤΤǤ θݤϡURLConnectionꤵλ(5ʬ)˥쥹ݥ󥹤ʤȯޤΥǤϡ٥ƥȤʳˤƽƳǧ줿ȤΤȤǤ ʤȤ⡤Τ褦٤ΤʬƱԤ߷פ򤱤롥ǡϤ줿ʳǥ쥹ݥ󥹤֤ʤꤷƤС̵̤ʥͥĥ³뤳ȤʤǤ礦ӥظªå󥰤Ԥۤ(ơǽʤǥѥŬѤơåɤθ³å塼¸ޥ͡㥯饹ۤǤ)ɤ⤷ʤǤ͡ ʬϷײŪˡ֥ʤˤƤС⤽ɤĤ˥åȤʤƸݤϵʤǤ礦Υ٥ƥȻΤΤʤΤǡ٤ϻʤ̤⤢ΤǤϤ٤äƤڤʤΤǤ͡ ŤΤȤʤưΤˤϼʤʤƤΤϡ˻٤⤤ȤʤΤǤϤʤǤ礦δطǤɤƤƥȤλ֤ʤȤ⤢ޤΥåץǡȤϡΤǤΤ1.5ޤľʤä褦ʤΤ񤷤Ǥɤ⡥

Forex Groups - Tips on Trading

Related article:
http://d.hatena.ne.jp/unep/20071031/1193843164

comments | Add comment | Report as Spam


"??URLConnection,??????" posted by ~Ray
Posted on 2007-12-15 15:07:22

1:问题,有很多新闻,需要生成静态页面 假设新闻访问url为:http://wwww cao com/newsAction do?newId=001 -------------------------------------------------------------------start------------------- import java io. FileOutputStream;merchandise java io. InputStream;merchandise java io. OutputStream;import java net. URL;merchandise java net. URLConnection; public static cancel main(arrange[] args) { URLClient client = newURLClient(); client urlToFile("http://wwww cao com/newsAction do?newId=001","c:\\001 htm");} public cancel urlToFile(arrange urlString. arrange filePath) { try { URL url =new URL(urlString); URLConnection conn = url openConnection(); OutputStream out = new FileOutputStream(filePath); byte[] b =new byte[1024]; while(in read(b) != -1) { out write(b); } in change state(); out close(); } catch (Exception e) { e printStackTrace(); }}} -----------------------------end------------------------- 这样修改可以解决字节不准确的错误。但是有的网页编码不同也会出现错误。 OutputStream out = new FileOutputStream(filePath); byte[] b =new byte[1024]; while(in read(b) != -1) { out write(b); } InputStreamReaderreader = new InputStreamReader(in,Charset forName("UTF-8")); OutputStreamWriterout = new FileWriter(filePath); burn[] b =new burn[4096]; int i=reader construe(b); while (i !=-1) { out create verbally(b,0,i); i= reader construe(b); } 这样就可以解决编码问题,现在只适用了utf-8的,其他编码没有试验。 ps:在最后一次修改时,出现另外一个问题,就是网页上的编码。 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />,出来之后就会出现编码,如果只有

Forex Groups - Tips on Trading

Related article:
http://blog.sina.com.cn/s/blog_4c9fd8ee01000d9d.html

comments | Add comment | Report as Spam


"urlconnection - formatting problems." posted by ~Ray
Posted on 2007-12-09 13:40:05

Morning all,Im working right now on a problem that i created. We undergo a jsp register which is used to create a formatted create to thescreen. This jsp register was written with all the code basically on thesame like when the lie wrapped a <%-- --%> was used to escape thereturn engrave because the result i get now that ive reformatted itis:--ObjectID:89call:The Object-----and so on. Does anyone know how to make a jsp summon ignore formatting done simplyto lay the code out in a more understandable way?.

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2007-10/msg02208.html

comments | Add comment | Report as Spam


"urlconnection - formatting problems." posted by ~Ray
Posted on 2007-12-09 13:40:03

Morning all,Im working alter now on a problem that i created. We have a jsp file which is used to print a formatted output to thescreen. This jsp file was written with all the code basically on thesame like when the line wrapped a <%-- --%> was used to flee thereturn character because the result i get now that ive reformatted itis:--ObjectID:89Title:The Object-----and so on. Does anyone know how to alter a jsp page do by formatting done simplyto lay the code out in a more understandable way?.

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2007-10/msg02208.html

comments | Add comment | Report as Spam


"urlconnection - formatting problems." posted by ~Ray
Posted on 2007-12-09 13:39:57

Morning all,Im working alter now on a problem that i created. We have a jsp file which is used to print a formatted create to thescreen. This jsp file was written with all the label basically on thesame desire when the lie wrapped a <%-- --%> was used to escape thereturn engrave because the prove i get now that ive reformatted itis:--ObjectID:89Title:The Object-----and so on. Does anyone know how to make a jsp page ignore formatting done simplyto lay the label out in a more understandable way?.

Forex Groups - Tips on Trading

Related article:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.programmer/2007-10/msg02208.html

comments | Add comment | Report as Spam


"URLConnection problem" posted by ~Ray
Posted on 2007-11-27 20:04:27

You're currently browsing the Java section within the Software Development category of DaniWeb a massive community of 240,105 software developers web developers. Internet marketers and tech gurus who are all enthusiastic about making contacts networking and learning from each other. In fact there are 2,385 IT professionals currently interacting right now! If you are in the IT industry or are just a technology enthusiast you might sight just what you're looking for in DaniWeb only takes a minute and lets you apply all of the interactive features of the place. I`m trying to compile a small program for authentication on a torrent place but when it reaches the setRequestProperty() lie throws an exception:Exception in go "main" java lang. IllegalStateException: Already connected at sun net. obtain) at MovieCrawler main(MovieCrawler java:22)I understand that something is already connected! How can I undo before using this method;here is the code: merchandise java net.*;merchandise java io.*;public categorise MovieCrawler { public static void main(String[] args) throws Exception { URL url = new URL("http://www torrentleech org/login php"); URLConnection uCon = url openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(uCon getInputStream())); arrange inputLine; while ((inputLine = in readLine()) != null) System out println(inputLine); in close(); //for (int i=0;i<20;i++) // System out println(uCon getHeaderFieldKey(i)+": "+uCon getHeaderField(i)); //System out println("kaaaaaaaaaaaaaa: "+uCon getRequestProperty("Cookies")); arrange uspass = "***:***"; uCon setRequestProperty("Authorization","Basic"+uspass); uCon connect(); BufferedReader in2 = new BufferedReader(new InputStreamReader(uCon getInputStream())); inputLine = ""; while ((inputLine = in2 readLine()) != null) System out println(inputLine); in2 close(); }} hit the books to see in another's calamity the ills which you should forbid. Publilius Syrus(~100 BC) If we helped you to understand your problem answered your challenge please attach your post as SOLVED.

Forex Groups - Tips on Trading

Related article:
http://www.daniweb.com/forums/thread94184.html

comments | Add comment | Report as Spam


"URLConnection getInputStream()" posted by ~Ray
Posted on 2007-11-17 15:47:45

Hi guys. I am writing an applet that is getting information from a php file. I am opening a connection to the php and posting to it then I am opening an input stream from the connection and reading from it. From the enter stream. I can easily change state a stream reader and read the data from it but when I try to pass the enter stream to another answer the schedule stalls indefinitely. Here is an example: OutputStreamWriter(conCon getOutputStream());conOut write(conPost);conOut flush();conOut change state();InputStream conIS = conCon getInputStream();BufferedReader buff = This is just an example. I am doing other things with the input stream. Is there any way to stop it from stalling here?Edited by: shiroganeookami on Oct 19. 2007 9:21 AM when I try to pass the input be adrift to another answer the program stalls indefinitely How is the code you posted which has nothing to do with this "another function" relevant to the problem?Your "another answer" apparantly has an infinite loop built into it or other kind of issue. Edit: I posted the above before you edited your post. From the new code you posted. I don't accept you. Functionally they do the same thing so either you've misdiagnosed where the problem occurs or one of the times you ran it the connection to the server (where the php resource is) timed out while waiting for its response. come up you're right about one thing. The two codes should do the same thing. Sadly they don't. I've got print statements after practically every lie of my code and it definitely stops there. The former label sometimes stops which I attributed to the occasional bad connection but the latter label never works. This isn't the only place that I do this. I've got functions that undergo worked well with all other enter streams but now they stop right as this input stream is passed in. Those two pieces of code you posted would behave identically. However that isn't the real method alter? You said: This is just an example. I am doing other things with the input stream. I guess the "other things" you are doing undergo something to do with the problem. One thing I notice about that code is that it will impel an unchecked exception if you read a line containing zero characters. In the environment you are running in can you identify "crashed" from "stalled"? shiroganeookami wrote:well here's the actual label:... I don't see anything in that which would bear badly other than possibly not checking your initially read string for null or checking string lengths before trying to use charAt(0) on it. I do see that you're conditionally building a "seq" string and then tossing it returning only the measure line (or null) you read so that doesn't look right. But it doesn't be desire it could possibly be the problem leading to this topic. Looks like you exceed do some (more) debugging by running in a debugger if possible or at a minimum logging clues along the way such as putting aSystem out println("Here's the line I just construe from the stream:" + line + ":");in the do-while loop to see if it's getting in there and what you're reading from the be adrift. And log other clues as come up such as at the end of the method to let yourself know whether the method returned or not and before and after each br readLine to let yourself know whether the readLine is hanging. Thanks guys. I'll try all of that. The code actually returns seq. I had just changed it for a back up and didn't cognise when I posted it. I'll add in the checks for null. Hopefully that will fix some problems. The code apparently works sometimes. I just have to try about 20 times before it actually loads the InputStreams. I'm not sure why it works more often when I don't pass it into another method but at least i know it does work.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5227967

comments | Add comment | Report as Spam


"trying to access HTML data from an Input stream of a URLConnection" posted by ~Ray
Posted on 2007-11-09 17:19:58

What I want to do is find the HTML contents of a webpage specified by the communicate represented by the arrange temp. This is from inside an applet. What I am getting is try { userUrl = new URL(temp); } catch (Exception e) { UrlOnError = adjust; } URLConnection con = (URLConnection) userUrl openConnection(); InputStream IStream = (InputStream) con getInputStream(); byte[] bbb = new byte[100]; IStream construe(bbb. 0. 100); arrange sss = bbb toString();what I am getting in sss is of the create "[B@xxxxxxx" where xxxxxxx appears as five to seven digits in hexadecimal. My questions are (1) what is this that I am getting and (2) how might I go about getting what I want (in this case just the first 100 characters) bbb toString() doesn't convert the contents of 'bbb' to a String. It returns whatever bbb toString() is defined to do. In this case it is only what disapprove toString() is defined to do as byte[] extends disapprove and can't possibly have a toString() method of its own. Have a look at the various constructors for String. Also you are ignoring the prove returned by InputStream construe() which will mean that (a) you won't spot EOS and (b) you will probably consider cast aside characters from bbb[] in your output. Don't do that. Oh yes that worked. Yay!arrange sss = new arrange(bbb);I'm glad it was that simple. I'm getting what I expected to get. And... I was actually consciously aware that the construe method had a go write. I just didn't care about it at the moment because I'm only trying to figure out how things bring home the bacon. I understand your concern there... I would never refer something desire that.

Forex Groups - Tips on Trading

Related article:
http://forum.java.sun.com/thread.jspa?threadID=5214978

comments | Add comment | Report as Spam


"Networking" posted by ~Ray
Posted on 2007-11-03 13:51:25

As far as a program is concerned a communicate is just another possible obtain of input data and another displace where data can be create. That does oversimplify things because networks are not as easy to work with as files are. But in Java you can do network communication using input streams and create streams just as you can use such streams to communicate with the user or to work with files. Nevertheless opening a communicate connection between two computers is a bit tricky since there are two computers involved and they undergo to somehow agree to change state a connection. And when each computer can displace data to the other synchronizing communication can be a problem. But the fundamentals are the same as for other forms of I/O. One of the standard Java packages is called java net. This package includes several classes that can be used for networking. Two different styles of network I/O are supported. One of these which is fairly high-level is based on the World-Wide Web and provides the choose of network communication capability that is used by a Web browser when it downloads pages for you to believe. The main classes for this style of networking are java net. URL and java net. URLConnection. An object of type URL is an consider representation of a Universal Resource Locator which is an address for an HTML document or other resource on the Web. A URLConnection represents a communicate connection to such a resource. The second style of I/O which is more general and much more important views the network at a displace aim. It is based on the idea of a socket. A socket is used by a program to open a connection with another program on a communicate. Communication over a communicate involves two sockets one on each of the computers involved in the communication. Java uses a categorise called java net. Socket to be sockets that are used for network communication. The term "socket" presumably comes from an visualise of physically plugging a wire into a computer to open a connection to a network but it is important to understand that a socket as the call is used here is simply an object belonging to the categorise Socket. In particular a schedule can have several sockets at the same measure each connecting it to another schedule running on some other computer on the communicate. All these connections use the same physical network connection. This section gives a apprise introduction to these basic networking classes and shows how they relate to input and create streams.--------------------------------------------------------------------------------11.4.1 URLs and URLConnections The URL categorise is used to represent resources on the World-Wide Web. Every resource has an communicate which identifies it uniquely and contains enough information for a Web browser to find the resource on the network and acquire it. The communicate is called a "url" or "universal resource locator."An object belonging to the URL class represents such an communicate. Once you undergo a URL disapprove you can use it to change state a URLConnection to the resource at that address. A url is ordinarily specified as a string such as "http://math hws edu/eck/index html". There are also relative url's. A relative url specifies the location of a resource relative to the location of another url which is called the base or context for the relative url. For example if the context is given by the url http://math hws edu/eck/ then the incomplete relative url "index html" would really have in mind to http://math hws edu/eck/index html. An object of the categorise URL is not simply a string but it can be constructed from a string representation of a url. A URL object can also be constructed from another URL object representing a context and a arrange that specifies a url relative to that context. These constructors have prototypespublic URL(String urlName) throws MalformedURLExceptionandpublic URL(URL context. String relativeName) throws MalformedURLExceptionNote that these constructors ordain throw an exception of write MalformedURLException if the specified strings don't represent legal url's. The MalformedURLException categorise is a subclass of IOException and it requires mandatory exception handling. That is you must call the constructor inside a try. catch statement that handles the exception or in a subroutine that is declared to throw the exception. The second constructor is especially convenient when writing applets. In an applet two methods are available that provide useful URL contexts. The method getDocumentBase() defined in the Applet and JApplet classes returns an object of write URL. This URL represents the location from which the HTML summon that contains the applet was downloaded. This allows the applet to go approve and retrieve other files that are stored in the same location as that document. For example,URL url = new URL(getDocumentBase(). "data txt");constructs a URL that refers to a file named data txt on the same computer and in the same directory as the source register for the web page on which the applet is running. Another method getCodeBase().

Forex Groups - Tips on Trading

Related article:
http://javasite.blogspot.com/2007/08/networking.html

comments | Add comment | Report as Spam


 

 




blogs - aa blogs - air force blogs - aquarius blogs - aries blogs - army blogs - arts blogs - baby blogs - blogs 4 men - blogs 4 women - cancer blogs - capricorn blogs - career change blogs - choice blogs - christmas blogs - cigar blogs - cigarette blogs - cig blogs - coast guard blogs - coffee bean blogs - college baseball blogs - college basketball blogs - college football blogs - colleges blogs - computer blogs - create blogs - dating blogs - elvis blogs - email chat blogs - email pal blogs - enhancement blogs - fall blogs - fha blogs - freedom blogs - friendly blogs - funny blogs - gambler blogs - gemini blogs - her blog - his blog - hockey blogs - join blogs - javas blogs - kid safe blogs - leo blogs - libra blogs - apartments blogs - coffees blogs - horoscopes blogs - life advice blogs - lover blogs - marine blogs - married blogs - military blogs - misc blogs - more money blogs - mortgage blogs - move blogs - movies blogs - musical blogs - navy blogs - new in town blogs - obscure blogs - online date blogs - online game blogs - over 30 blogs - over 40 blogs - over 50 blogs - over 60 blogs - over 70 blogs - over 80 blogs - over 90 blogs - password blogs - pc blogs - mortgages blogs - peoples blogs - pictures blogs - pipe blogs - pisces blogs - poems blogs - poker blogs - police blogs - political blogs radio blogs - read blogs - recreational vehicle blogs - relocation blogs - reserve blogs - rv blogs - safe blogs - scorpio blogs - singles blogs - smokers blogs - smoker blogs - state blogs - state college blogs - taurus blogs - teen advice blogs - teenager blogs - tobacco blogs - tv blogs - vacation blogs - veteran blogs - virgo blogs - virtual blogs - weekly blogs - wingman blogs - word blogs - words blogs - writer blogs - poetry blogs - prescription blogs - sagittarius blogs - straight blogs - summer blogs - gi blogs - hooka blogs - penis enlargement blogs - vfw blogs - casinos blogs - casino blogs - web hosting blogs - hosting blogs - auto blogs - truck blogs - van blogs - suv blogs - 4 wheel blogs - harley blogs - flu blogs - diet blogs - pistols blogs - teenage blogs - lpga blogs - burnable blogs - new tunes blogs - coaching blogs - treasures blogs - trades blogs - nutty blogs - skate blogs - play 21 blogs - weather blogs - poker players - golf blogs - american blogs - football blogs - baseball blogs - hockey blogs - basketball blogs - soccer blogs - cooking blogs - recipe blogs - space blogs - 3d games blogs - barbecue blogs




the urlconnection archives:

11 articles in 2006-01
22 articles in 2006-02
27 articles in 2006-03
36 articles in 2006-04
27 articles in 2006-05
26 articles in 2006-06
24 articles in 2006-07
18 articles in 2006-08
22 articles in 2006-09
30 articles in 2006-10
22 articles in 2006-11
22 articles in 2006-12
12 articles in 2007-01
12 articles in 2007-02
3 articles in 2007-03
7 articles in 2007-04
11 articles in 2007-05
10 articles in 2007-06
3 articles in 2007-07
1 articles in 2007-09




next page


urlconnection