2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
I received an email stating that AOL finally aband...
TOP THREE LINKS YOU MUST CLICK ON
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

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

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

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!

I am very happy with your code, Yakov.
I tried it and everything works very well.
Thanks Ferruccio

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 ();

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?

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("");
}
}

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.

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.

I add to my above question: how can I pass the parameter values calling the URL?

What about reading a CGI URL accepting METHOD=POST parameters?

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.

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?

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.

Very useful, clear.


Feedback Pages:


FEATURED WHITE PAPERS
YOUR FEEDBACK
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,...
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...
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 ...
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...
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 ...

What's the key to team and individual developer productivity in maintaining and extending a large ap...
An applet, a Java program that runs in a browser, often has to access the client resources. However,...
Three-letter acronyms (TLAs) are hardly new in Information Technology: EAI, ESB, SOA, BPM, BAM, ETL,...
Furthering its dedication to providing Java developers productivity with choice, Oracle announced th...
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe ...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Man...
Government intervention and direction has long been critical to the development of the computer indu...
Commercial systems are developed with a huge range of performance requirements and we are concerned ...
Genuitec announced the availability of MyEclipse Enterprise Workbench 7.0 milestone 1. This mileston...
Genuitec announced the availability of the first milestone release of MyEclipse 7.0 Blue Edition. Th...
Clear Toolkit 3.0 is a set of components, code generators, and plugins created by software engineers...
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft...
The pressure is on to keep pace with Web 2.0 entrants into the marketplace. Rewriting is expensive; ...
Aerial and satellite imagery, topographic maps, and terrain data available from ESRI's ArcGIS Online...
"Advertising on Google.com is contextual, requires no personally identifiable information, is not pr...
In this session that no developer who uses JavaScript or ActionScript will want to miss, delegates w...
With the rapid evolution that Java and open source frameworks have made since the release of J2EE, e...
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...
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 ...
2008 is going to be an important year for Rich Internet Applications. Most organizations are deliver...
The OpenAjax Alliance is developing an Ajax industry wishlist for future browsers, using a dedicated...
In every field of design one of the first things students do is learn from the work of others. They ...
Infragistics announced the availability of two Community Technology Preview (CTP) User Interface (UI...
The YUI development team has released version 2.5.2; you can download the new release from SourceFor...
ADS BY GOOGLE