This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use Servlet to read a webpage.

 
CC Huang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic