This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 12761
    
    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
 
 
subject: Use Servlet to read a webpage.
 
Similar Threads
send the message to websphere MQ through servlet.
hit counter
init and service in same thread?
Calling windows event "Save As" from JSP
Servlet to servlet