O'Reilly logo

J2EE™ Tutorial, The by Beth Stearns, Monica Pawlan, Eric Jendrock, Kim Haase, Dale Green, Stephanie Bodoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

URL Connections

A Uniform Resource Locator (URL) specifies the location of a resource on the Web. The HTMLReaderBean class shows how to connect to a URL from within an enterprise bean.

The source code for this example is in the j2eetutorial/examples/src/ejb/htmlreader directory. To compile the code, go to the j2eetutorial/examples directory and type ant htmlreader. A sample HTMLReaderApp.ear file is in the j2eetutorial/examples/ears directory.

The getContents method of the HTMLReaderBean class returns a String that contains the contents of an HTML file. This method looks up the java.net.URL object associated with a coded name (url/MyURL), opens a connection to it, and then reads its contents from an InputStream. Before deploying the application, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required