 | I received an email stating that AOL finally aband... |
|
TOP THREE LINKS YOU MUST CLICK ON
FrontPage Feature
Reading Data from the Internet
Yakov shows that working with the streams over the Internet may be as simple as dealing with files on your local disk, in the sixth installment of Java Basics.
Reader Feedback: Page 1 of 2
#19 |
Dave Mason commented on 18 Oct 2007
Hello Yakov,
how can I read data in real time from java applet for example:
http://www.saxobank.com/?id=911&Lan=EN&Au=1&Grp=5
|
#18 |
nitin commented on 27 Nov 2004
hi,
can any one tell me how can i read the parameters from URL that has been passed by someone ie id someone send id=123 then how can i get it,how the whole process work & last but the mostimp i want to do whole thing through core java.
Bye
|
#17 |
MIchael Behrens commented on 8 Feb 2004
Great Article! Keep''m coming!
There is also a good WebCopy implementation at:
http://www.acme.com/java/software/
It makes all the web references local - It does not work on HTTPS - I wish I had all the know-how & code to make an equivalent HTTPS WebSiteReader, which would be very handing for testing our query pages.
Thanks!
|
#16 |
Ferruccio Spagna commented on 31 Jan 2004
I am very happy with your code, Yakov.
I tried it and everything works very well.
Thanks Ferruccio
|
#15 |
In this lesson I do this using HTTP GET request by attaching parameters to the URL after a question mark separated with an ampersand.
Fo HTTP POST, after getting the URLConnection stream, do something like this:
urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
urlConn.setDoOutput(true);
String myData = "myParam1=" + URLEncoder.encode ("abc") +
"&myParam2=" + URLEncoder.encode ("xyz");
DataOutputStream encodedParams = new DataOutputStream (urlConn.getOutputStream ());
encodedParams.writeBytes (myData);
encodedParams.flush ();
encodedParams.close ();
|
#14 |
Ferruccio Spagna commented on 31 Jan 2004
Ok. What you say occurs when you have a page with a form. Well known. But my question was: you want to read the stream (see your last article) and perhaps manipulate it. You then use the code:
java.net.URL url = new java.net.URL("http://www.cgi.com");
java.net.URLConnection c = url.openConnection();
java.io.DataInputStream dis = new java.io.DataInputStream(c.getInputStream());
and so on.
How can you give the parameters to the cgi with THESE code lines?
|
#13 |
Well, here''s the sample from my book "The Java Tutorial for the Real World".
1. An HTML form has 2 fields to perform a book search:
Find a book
Enter a word from the book title:
2. The servlet FindBooks runs on the server side, gets the parameters and sends back to the browser a page that reads that this book cost $65:
public class FindBooks extends javax.servlet.http.HttpServlet {
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException {
String title;
PrintWriter out = res.getWriter();
title = req.getParameter("booktitle");
res.setContentType("text/html");
out.println("");
out.println("the book "+title+" costs only $65");
out.println("Please enter your credit card number");
out.println("");
}
}
|
#12 |
Ferruccio Spagna commented on 31 Jan 2004
Thank you for your answer. I have several good Java books, but I didn''t find how I can read a CGI URL stream passing POST parameters in the calling instruction anywhere. Tell me please in a few words the way, if it is possible.
|
#11 |
Ferruccio,
Java Servlets and JavaServer Pages technologies deal with HTTP Post and Get requests, parameters, etc. Wait for my lesson on servlets, or get a good book if you need to know the answer now.
|
#10 |
Ferruccio Spagna commented on 30 Jan 2004
I add to my above question: how can I pass the parameter values calling the URL?
|
#9 |
Ferruccio Spagna commented on 30 Jan 2004
What about reading a CGI URL accepting METHOD=POST parameters?
|
#8 |
Dennis,
You can run on the remote machine one of the following: RMI server, SocketServer, a Servlet,FTP server... that has to create an instance of the class java.io.File that points at your directory. The File.list() will return the list of files in this directory as a String array. Now create instances of File for each of the array elements and call File.lastModify() to check the timestamp. After finding the file with the proper date, send its URL (or a stream reference) to the client for reading.
|
#7 |
Dennis Christopher commented on 29 Jan 2004
I found the article useful, and above average in clarity.
I am wondering if anyone knows how you set up the
connection to download an (entire) directory of files?
and to check the file dates before doing so?
|
#6 |
Yakov,
You should mention that HttpURLConnection may ''hang'' when contacting servers that don''t behave correctly. This can cause a lot of problems in a server side application. The solutions are:
1) Use something other than URL/URLConnection/HttpURLConnection.
2) Set the system properties that control the socket timeouts for the Sun HTTP client.
|
#5 |
John Pantone commented on 26 Jan 2004
Very useful, clear.
|
YOUR FEEDBACK  | By Joe Winchester James Nelson wrote: Thanks for the posting, which we are hoping will solve our software issue with two Turkish clients. This may be four years out of date, but please correct the code example, which has many nonsensical errors (two identical operations on anotherUserVisibleString, use of String tag without later reuse,... |  | By Matt Silver Ambuj wrote: Hi Matt,
I have some problem with retrieving the producer, when i am entering the wsdl of my service(https) which is in WSRP and hosted on IIS, then its saying unable to retrieve producer.
And if i try the same in IE its getting the wsdl, now can you tell me where i am missing the configuration... |  | By David Hardwick Aymen wrote: I'd like to think you for this article, good and simple!
While reading, I was wondering how could we manage 'Roles'? Can we add meaning to roles ? And build them based on rights (MANAGER_ROLE=READ, WRITE, DELETE ... |  | By Jason R Briggs Stella Mc.Ligger wrote: Insiders of the company, on condition of anonymity, stated that SWAROVSKI has successfully won the bid over the other foreign MNC Giants for a multi-million dollar contract with Nanogum , to design and manufacture a unique crystal case for this exclusive platinum gum. Senior officials in the Swarovs... |  | By Raj Sheelvant Bruce Arnold wrote: Kudos to the Cloud Crowd for Re-Inventing the Wheel!
One thing 30 years in the IT industry has taught me is that the more things change, the more they stay the same. Another is that the only memory we seem to access is short-term. A third is that techno-marketeers rely on that, so they can put... |
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS |
SYS-CON FEATURED WHITEPAPERS BREAKING JAVA NEWS
SpringSource, a leading provider of infrastructure software and the
company behind ... Aug. 27, 2008 08:13 AM |
 | By Ravi Kumar What's the key to team and individual developer productivity in maintaining and extending a large ap... | By Maha Sengottiyan An applet, a Java program that runs in a browser, often has to access the client resources. However,... | By Prabhu Balashanmugam; Yanbing Lu Three-letter acronyms (TLAs) are hardly new in Information Technology: EAI, ESB, SOA, BPM, BAM, ETL,... | By Eclipse News Desk Furthering its dedication to providing Java developers productivity with choice, Oracle announced th... | By RIA News Desk Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe ... | By Virtualization News Desk Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Man... | By Patrick Curran Government intervention and direction has long been critical to the development of the computer indu... | By Adrian Marriott Commercial systems are developed with a huge range of performance requirements and we are concerned ... | By RIA News Desk Genuitec announced the availability of MyEclipse Enterprise Workbench 7.0 milestone 1. This mileston... | By RIA News Desk Genuitec announced the availability of the first milestone release of MyEclipse 7.0 Blue Edition. Th... | By Flex News Desk Clear Toolkit 3.0 is a set of components, code generators, and plugins created by software engineers... | By Virtualization News Desk Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft... | By RIA News Desk The pressure is on to keep pace with Web 2.0 entrants into the marketplace. Rewriting is expensive; ... | By Java News Desk Aerial and satellite imagery, topographic maps, and terrain data available from ESRI's ArcGIS Online... | By Search News Desk "Advertising on Google.com is contextual, requires no personally identifiable information, is not pr... | By RIA News Desk In this session that no developer who uses JavaScript or ActionScript will want to miss, delegates w... | By Jay Blanton With the rapid evolution that Java and open source frameworks have made since the release of J2EE, e... | By RIA News Desk jQuery is a rapidly growing, popular JavaScript library. Its powerful and modular architecture, whic... | SQL Injection attacks are one of the easiest ways to hack into a website. One recent hack, using a s... | By SOA World Magazine News Desk SOA World Magazine announced today that the polls are now open for the SOA World Magazine Readers' C... |
SPONSORED BY INFRAGISTICS There are many forces that influence technological evolution. After a decade of building enterprise ... Jun. 30, 2008 03:45 PM | 2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver... Jun. 20, 2008 12:45 PM | The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated... Jun. 18, 2008 07:45 PM | In every field of design one of the first things students do is learn from the work of others. They ... Jun. 11, 2008 10:30 AM | Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI... Jun. 4, 2008 08:00 AM | The YUI development team has released version 2.5.2; you can download the new release from SourceFor... Jun. 2, 2008 05:00 AM |
|