aspose file tools
The moose likes Servlets and the fly likes Use Servlet to read a webpage. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 12268
    
    1
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Use Servlet to read a webpage.
 
Similar Threads
init and service in same thread?
hit counter
Servlet to servlet
Calling windows event "Save As" from JSP
send the message to websphere MQ through servlet.