File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Use Servlet to read a webpage. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Use Servlet to read a webpage. " Watch "Use Servlet to read a webpage. " New topic
Author

Use Servlet to read a webpage.

CC Huang
Greenhorn

Joined: Jun 27, 2002
Posts: 1
Using Servlet, how can I read a webpage via internet into a string object. The webpage could be HTML or JSP.
Thanks,
Brian Glodde
Ranch Hand

Joined: Jun 27, 2001
Posts: 171
You'll be using a URLConnection object, then use a DataInputStream to retrieve the output of the page (if it's a server side script). You could then store it in a String or a File structure.
Hope that helps!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
Note that if you use a url starting "http://" you automatically get a HttpURLConnection so look in those docs for the methods that let you set request headers etc.
Bill


Java Resources at www.wbrogden.com
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Use Servlet to read a webpage.
 
Similar Threads
Calling windows event "Save As" from JSP
Servlet to servlet
send the message to websphere MQ through servlet.
hit counter
init and service in same thread?